The adapt function

In the CoffeeRoastingNumpy lab, the ‘adapt()’ is a new function I wasn’t aware of, and to fully grasp the implementation, I created a (4,2) array, then applied the adapt function to learn the variance and mean, when I printed out the result I got an error .

Error Message:
Failed to find data adapter that can handle input: <class ‘NoneType’>, <class ‘NoneType’>

The code:

import numpy as np
x = np.array([[10, 20, 50,100],[1,2,3,4]])
x = x.transpose()

from keras import layers
import tensorflow as tf
x_norm = tf.keras.layers.Normalization(axis=-1)

x_norm.adapt(x)
xn = x_norm(x)

Hello @E_Jimmy,

Your code runs successfully on my machine. Would you like to restart the kernel and run it again?

Screenshot from 2022-10-21 16-17-52

Raymond

Thanks, it worked.

the ‘lab_utils_common.py’ used in not part of the lab files, how can I access it?

Go to the lab that uses “lab_utils_common.py” on coursera, click “File” > “Open”, then you should see that python file in the opened file browser. If you can’t see it, then in the top right corner of the file browser, click “Help” > “Get Latest Version” > “Update Lab”, then any missing file should come back.