My original code looks like this, it runs on my laptop but not on my friend’s:
rnn = RNNClassifier(num_epochs=20, lstm_units=50, dropout_rate=0.5)
rnn.fit(X_train, y_train)
And the error looks like this:
Epoch 1/30
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-16-0eb094b85c44> in <cell line: 3>()
1 #YOUR CODE HERE! Replace the nones!
2 rnn = RNNClassifier(num_epochs=30, lstm_units=50, dropout_rate=0.5)
----> 3 rnn.fit(X_train, y_train)
2 frames
/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py in tf__train_function(iterator)
13 try:
14 do_return = True
---> 15 retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
16 except:
17 do_return = False
ValueError: in user code:
File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 1401, in train_function *
return step_function(self, iterator)
File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 1384, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 1373, in run_step **
outputs = model.train_step(data)
File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 1150, in train_step
y_pred = self(x, training=True)
File "/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/input_spec.py", line 235, in assert_input_compatibility
raise ValueError(
ValueError: Exception encountered when calling layer 'sequential' (type Sequential).
Input 0 of layer "lstm" is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (32, 1)
Call arguments received by layer 'sequential' (type Sequential):
• inputs=tf.Tensor(shape=(32, 1), dtype=string)
• training=True
• mask=None
I tried to switch to another google account as it’s on the free version of Colab, I also tried to run all cells again, and split up the code into multiple cells. I kept getting this same error.