Problem
Create a tf.data.Dataset object from a numpy array that contains multiple X array.
Explaination
This is the model that I'm using, some layers eliminated for reduce the image:
As you can see, the model contains two different input:
- The data itself (shape [Batch, 730, 1]) (from now called
x_train) - The timestamp (shape [Batch, 730, 3]) (from now called
ts_train)
The problem that I'm aiming to solve is a timeseries forecast.
The x_train contains a single feature.
The ts_train contains three features that rappresent Year,Month,Day of the misuration.
I can fit/evaluate/predict the model without any particular problem.
Example of fit:
model.fit(
[x_train, ts_train],
y_train,
batch_size=1024,
epochs=2000,
validation_data=([x_test, ts_test], y_test),
callbacks=callbacks,
)
Example of predict:
model.predict([x_test[0].reshape(1, window, 1), ts_test[0].reshape(1, window, 3)])
However, i can't understand how to cast the numpy array that rappresent my dataset into a tensorflow dataset.
Using the following code:
tf.data.Dataset.from_tensor_slices([x_train, ts_train], y_train)
I'll receive the following error:
ValueError: Can't convert non-rectangular Python sequence to Tensor.
How can I cast my 2 x -> 1 y into a tf.data.Dataset ?