Why does this error come up?

If you are running your notebook in some different environment than the course website, you have to be very careful: versions of packages change rapidly in this space and there is no guarantee that things will just work with whatever versions you happen to have in your environment.

I added a print statement to that notebook to figure out what version of TF is being used in the course environment. Here’s what I get:

print(tf.__version__)
2.3.0

Here’s a thread put together by a fellow student which shows how to duplicate the course environment, although I’m not sure whether those instructions cover different versions of TensorFlow.