Callbacks in TF using MNIST

I’m getting error messages in cells that doesn’t require me to code.

grader-required-cell

Load the data

Get current working directory

current_dir = os.getcwd()

Append data/mnist.npz to the previous path to get the full path

data_path = os.path.join(current_dir, “data/mnist.npz”)

Discard test set

(x_train, y_train), _ = tf.keras.datasets.mnist.load_data(path=data_path)

Normalize pixel values

x_train = x_train / 255.0


NameError Traceback (most recent call last)
in
4
5 # Get current working directory
----> 6 current_dir = os.getcwd()
7
8 # Append data/mnist.npz to the previous path to get the full path

NameError: name ‘os’ is not defined

1 Like

Yoy probably forgot to run previous upwards cells of code, especially the line import os.

1 Like

I’m getting a syntax error in model.compile() function.

Posting code solutions is against honor of conduct

File “”, line 14
model.compile()
^
SyntaxError: invalid syntax

1 Like

Have a look on this method in Tensorflow, you are supposed to be using it according to these instruction.

compile

View source

compile(    optimizer='rmsprop',    loss=None,    metrics=None,    loss_weights=None,    weighted_metrics=None,    run_eagerly=None,    steps_per_execution=None,    jit_compile=None,    **kwargs)