I am struggeling a little bit with the tf.data.dataset API when I try to have multiple inputs for LSTM, that is for each feature a vector of length n (steps in time serie) and with, let us day, 5 features. Thus I have a list of 5 vectors with length, let us say, n=3.
For example I have a generator which yields in every step a data with the following structure:
[
array(
[
[5.00000000e-01, 5.00000000e-01, 5.00000000e-01],
[9.00000000e+00, 9.00000000e+00, 9.00000000e+00],
[7.00000000e+00, 9.00000000e+00, 1.00000000e+01],
[6.30841636e-03, 4.22776321e-02, 1.49106372e-02],
[4.00000000e+00, 1.00000000e+01, 2.20000000e+01]
]),
array(
[
[ 9, 9, 9],
[13, 13, 13]
]
)
]
and when I try to put it into the api with the code line:
tf.data.Dataset.from_generator(
generator=lambda: generator,
output_types=(
(
(tf.float32, tf.float32, tf.float32),
(tf.int32, tf.int32, tf.int32),
(tf.int32, tf.int32, tf.int32),
(tf.float32, tf.float32, tf.float32),
(tf.int32, tf.int32, tf.int32)
),
(
(tf.int32, tf.int32, tf.int32),
(tf.int32, tf.int32, tf.int32)
)
)
)
I get the error:
TypeError: generator yielded an element that did not match the expected structure. The expected structure was .... but the yielded element was ... .
What am I missing? How to write the correct output_shape? Or is it not possible to give the generator for tf.data a nested structure? How to handle multiple inputs and outputs with tf.data.dataset.from_generator?
Thanks in advance for any help.