I am doing simple sequence prediction. My model and data look like this:
def generate_rnn(input_shape):
In = Input(shape=(input_shape[1], 1))
x = LSTM(4)(In)
x = Flatten()(x) # I tried both with and without flatten, same results
Out = Dense(1)(x)
model = Model([In, Out])
model.compile(optimizer=Adam(), loss='MSE', metrics=['mse'])
return model
X = np.random.rand(100, 5)
y = np.random.rand(100, 1)
X = X.reshape(X.shape[0], X.shape[1], 1)
rnn = generate_rnn(X.shape)
rnn.fit(X, y, epochs=10)
Firtst time when I run the program, at function call rnn.fit()
I get following error message:
File "C:\Users\achib\Anaconda3\envs\deep\lib\site-packages\tensorflow_core\python\keras\backend.py", line 1237, in dtype return x.dtype.base_dtype.name
AttributeError: 'NoneType' object has no attribute 'dtype'
If I run rnn.fit()
again in console, I get following error message:
ValueError: ('Error when checking model target: expected no data, but got:',
And then my y
variable gets printed. I have worked with LSTM networks in Keras before, but its my first time encountering such an issue? Any help?
The documentation for the Model class ->https://keras.io/api/models/model/#model-class
According to this, Model class must receive input and output as different parameters and not as a part of the same list. That's what the-
ValueError: ('Error when checking model target: expected no data, but got:',
means. The model's target variable(y) is empty. So removing the square bracket should help.
Hope this helped.
May the force be with you.