Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

failure while creating Trainer #4

@slaweks17

Description

@slaweks17

Hi,
I am trying to port my Python program for time series forecasting (where it works). It is a regression style setup with both input and output being vectors. There are many time series, with varying lengths, but every point on a series is preprocessed to an input vector (of INPUT_SIZE), and at each point we also have the vector forecast (of OUTPUT_SIZE).

I am using stacked LSTMs, but to simplify matters, only single one here, created with this function:
createLSTMnet<-function(input_var , hidden_layer_dim1, output_dim) {
r=Recurrence(LSTM(hidden_layer_dim1,
use_peepholes=LSTM_USE_PEEPHOLES,
enable_self_stabilization=LSTM_USE_STABILIZATION, name="firstCell"))(input_var)
r=Dense(output_dim, bias=TRUE, name="lastLayer")(r)
}

I also use custom loss function:
sMAPELoss<-function (z, t){
t1=op_element_select(op_less(t,-0.9), z, t, name="t1")
a=op_abs(op_minus(t1,z))
b=op_plus(op_abs(t1),op_abs(z))
op_reduce_sum(op_element_divide(a,b))
}

The most important few more lines of code:
input_var <- seq_input_variable(INPUT_SIZE, name = "input")
output_var <- seq_input_variable(OUTPUT_SIZE, name = "label")

z = createLSTMnet(input_var, LSTM_STATE_SIZE, OUTPUT_SIZE)
loss = sMAPELoss(z,output_var) 
eval_error = loss
learner = learner_momentum_sgd(z$parameters, lr_schedule, mm_schedule,
		l2_regularization_weight = 0.0005, gaussian_noise_injection_std_dev = 0.0005)
trainer <- Trainer(z, c(loss, eval_error), learner)

And the last line fails with:
Error in py_call_impl(callable, dots$args, dots$keywords) :
TypeError: argument label's type Sequence[Tensor[2]] is incompatible with the type Sequence[np.float32] of the passed Variable

Could some kind soul help me please?

BTW, there is only the SGD learner available, right? No Adam, Adagrad, etc.
Any plans for brining the R functionality closer to the Python's one?

Regards,
Slawek

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions