Open vrunm opened 1 year ago
@vrunm, With the code provided above, we weren't able to analyse and provide the pointer to resolve the issue. Kindly find the gist of it here. So, could you please provide the complete code, dependencies and the tensorflow version you are trying. Thank you!
The code you have provided is correct. Since you don't have access to the original data the code does not run. I cannot provide the dataset details. Is the error due to the definition of the LSTM layer? I have looked extensively and could not find any other solutions to this error? I found a similar issue Link were the similar problem has been encountered but this issue has not fully been resolved yet.
I have the same issue, and have created a MWE here: https://colab.research.google.com/gist/Matt-Bailey-EcoSync/9d39319c92633448dc1e623d8ce91dcf/keras-nonetype-issue.ipynb
I've found that iterating over the dataset and fitting on batches manually works:
m1 = tf.keras.Model(encoder.inputs, decoder_outputs)
m1.add_loss(vae_loss2(encoder_inputs, decoder_outputs, z_log_sigma, z_mean)) #<===========
m1.compile(loss=None, optimizer='adam')
for feature, target in mwe_ds:
m1.fit(feature, target)
but fitting on the dataset directly does not work:
m1.fit(mwe_ds) # TypeError: 'NoneType' object is not subscriptable
However, running eagerly works (with a performance penalty):
m2 = tf.keras.Model(encoder.inputs, decoder_outputs)
m2.add_loss(vae_loss2(encoder_inputs, decoder_outputs, z_log_sigma, z_mean))
m2.compile(loss=None, optimizer='adam', run_eagerly=True)
m2.fit(mwe_ds)
Is there any progress on this?
Do RNNs work on other platforms, or not at all?
I am building a TensorFlow model that takes 4 inputs and gives 2 outputs. I first start with a pd.DataFrame:
Then, I use a generator to create the TensorFlow Dataset:
Here is what one "row" of train_ds looks like:
({"text": [1, 0, 0, ..., 1, 1], "prompt_question": [1, 0, 0, ..., 1, 1], "prompt_title": [1, 0, 0, ..., 1, 1], "prompt_text": [1, 0, 0, ..., 1, 1]}, {"content": 2, "wording": 1}))
Every value is a tensor.Note that I use a TextVectorization layer from keras:
At this point, train_ds contains no None values.
Here is my model:
I compile it like this:
model.compile(loss={"content": "mean_squared_error", "wording": "mean_squared_error"}, optimizer="adam")
The error occurs when I try to fit the model:
history = model.fit(x=train_ds, batch_size=32, epochs=20, callbacks=[callbacks])
Here is the traceback:It appears that the error rises because of the LSTM layer:
x = keras.layers.Bidirectional(keras.layers.LSTM(32))(embedded)