How much experience do you have using TensorFlow? I’ve never seen an optimizer used that way. In all the assignments that use TF here in the DLS courses, the pattern is this:
First you define your model by listing all the layers using the Keras Sequential or Functional APIs.
Then you “compile” the model. Here’s an example from DLS C4 W1 A2:
happy_model.compile(optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy'])
Note that this is part of the template code that they just gave us, so it’s ok to show it here. It’s not part of the code we need to write for the assignment.
Then finally you train the model using the optimizer and loss function you just defined like this:
happy_model.fit(X_train, Y_train, epochs=10, batch_size=16)
There are lots of places to look in the TF documentation for tutorial level information about topics like this. Here’s one such article, but you might want to read some of the previous articles that it mentions first.