Unable to use tf.linalg.l2_normalization() to keras layer

This is regarding week 2’s Practice Lab 2 where while building the the two
Neural networks for the user and the movies, I’m unable to use
tf.linalg.l2_normalization() as is shown in the online nb in my own system

image

But in my system, it throws me this error:

The code in my system is:

Could anyone help me in this,
Thank you,
Ayush C

There should be additional files in the File->Open section which may include further imports or function definitions that you might be missing in your own environment, check them out!

Thanks for the reply!,
I have checked it and everything seems to be right environment wise, but the same error message is shown

Perhaps this line might be the issue

#making sure that the magnitude of vu is always 1

sorry I am not that familiar with this course!

alright, will take a look, Thanks!

I was facing the same issue while trying to run it in a local machine. I’m not sure but it could be because of some TensorFlow version issue. But wrapping it up inside a Lambda layer of keras seems to work in my system.

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

ok will check this out :+1: