Deep Learning for Content Based Filtering Error

I don’t know why this error keeps coming up. Can someone help me what the issue may be?

Cell #14. Can’t compile the student’s code. Error: ValueError(‘in user code:

 File “/usr/local/lib/python3.7/site-packages/keras/engine/training.py”, line 1051, in train_function *
 return step_function(self, iterator)
 File “/usr/local/lib/python3.7/site-packages/keras/engine/training.py”, line 1040, in step_function **
 outputs = model.distribute_strategy.run(run_step, args=(data,))
 File “/usr/local/lib/python3.7/site-packages/keras/engine/training.py”, line 1030, in run_step **
 outputs = model.train_step(data)
 File “/usr/local/lib/python3.7/site-packages/keras/engine/training.py”, line 889, in train_step
 y_pred = self(x, training=True)
 File “/usr/local/lib/python3.7/site-packages/keras/utils/traceback_utils.py”, line 67, in error_handler
 raise e.with_traceback(filtered_tb) from None
 File “/usr/local/lib/python3.7/site-packages/keras/engine/input_spec.py”, line 264, in assert_input_compatibility
 raise ValueError(f'Input {input_index} of layer “{layer_name}” is '

 ValueError: Input 0 of layer “model” is incompatible with the layer: expected shape=(None, 100), found shape=(None, 14)
’)
Traceback (most recent call last):

Hello @Mir_Aayan,

I have edited your post to make the message prettier.

First, we need to locate Cell#14. We go to the assignment, from top to bottom, look for the 14th code cells and we should find this one:

This makes sense because this cell calls model.fit, and the error messages were all about kera’s training procedure.

Now what other hints do we have from the message? The following:

ValueError: Input 0 of layer “model” is incompatible with the layer: expected shape=(None, 100), found shape=(None, 14)

It said the model that you provided for training wanted an input with 100 features, but the lab was only giving 14 to it.

Now, 14 is the correct number, and 100 is wrong. You need to figure out where that 100 comes from.

If you go back to cell #12, it should have printed a summary of the model, and below is mine:

image

See that because num_user_features is 14, my model expects 14 features. Now yours is 100, why is that?

Note that the value of num_user_features is provided to you by the lab, and if you hadn’t changed it, it should remain 14. If you hadn’t changed to use num_user_features as the argument value for creating the Input layer, the model should expect 14 features. You might have changed something.

If you don’t know what you have changed, then I suggest you get a new copy of the notebook by following instructions in B5 of the MLS FAQ.

Cheers,
Raymond

Hey i finally managed to get it working! thank you