How to Solve NameError: name 'to_categorical' is not defined -- tensorflow

Solution: Import the 'to_categorical' module

To Solve the error, add the following line to the top of your code.

from tensorflow.keras.utils import to_categorical

 

For more information:
Python tensorflow to_categorical