Tutorial 20 ValueError in Keras
pairwiserr opened this issue · comments
tf.__version__
'2.0.0'
tf.keras.__version__
'2.2.4-tf'
On line 48
model.fit(x_train_pad, y_train, validation_split=0.05, epochs=3, batch_size=64
I get
ValueError: Tried to convert 'y' to a tensor and failed. Error: None values not supported.
I opened an issue keras-team/keras#13407
Solution is to convert all your lists to numpy array
e.g.
import numpy as np
x = np.array(x_train_pad)
y = np.array(y_train)
model.fit(x, y, validation_split=0.06, epochs=3, batch_size=64)
Also when you're loading tensorflow keras packages on line 2, change
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import Dense, GRU, Embedding
from tensorflow.python.keras.optimizers import Adam
from tensorflow.python.keras.preprocessing.text import Tokenizer
from tensorflow.python.keras.preprocessing.sequence import pad_sequences
to
from tensorflow.compat.v1.keras.models import Sequential
from tensorflow.compat.v1.keras.layers import Dense, GRU, Embedding
from tensorflow.compat.v1.keras.optimizers import Adam
from tensorflow.compat.v1.keras.preprocessing.text import Tokenizer
from tensorflow.compat.v1.keras.preprocessing.sequence import pad_sequences
I think tf 2.0 broke some of the utility functions when calculating gradients.
Your post is too short. I have to guess most of the context. Are you running the tutorial exactly like it is in the repo? Are you using another dataset? If you're running it exactly like it is in the repo, then it's perhaps a tensorflow 2.0 problem. At some point I will go through all the tutorials and see if I can update them to TF 2.0. Using compat.v1 is only a temporary fix.
Sorry, I should've prefaced that I am running the notebook exactly as is, line by line, using the same dataset with your download.py
and imdb.py
.