Unable Run C3 W2 RecSysNN Assignment On My Computer

I’ve finished this assignment without experiencing any problem. Then, I want to do some experiment on my computer but I have some issues to run the code. I think using a different Keras version is producing an error. I have the Keras version 3. On Coursera, the version is 2. A screenshot of this issue is here:

How can we overcome this problem?

Hi Anıl, welcome to the community!

Since the Coursera course uses Keras 2, the easiest solution is to downgrade Keras to version 2: pip install keras==2.11.0. Make sure to restart your kernel after downgrading.

If you prefer to keep Keras 3, try wrapping vu in a Lambda layer instead of using tf.linalg.l2_normalize directly. For example:

from tensorflow.keras.layers import Lambda

vu = Lambda(lambda x: tf.linalg.l2_normalize(x, axis=1))(vu)

Hope this helps!

1 Like

That helped, thank you!

For those who want to keep Keras 3 like me I’d like to remind that you also require to replace all layer.output.shape.as_list() with list(layer.output.shape) in the public_tests.py file.

1 Like

Note for other students who may find this thread:

You should not modify the Keras version or the public_tests.py file if you expect your work to be graded on Coursera.

1 Like