C1W4 Assignment - Syntax Error

Hi,

Im, doing the training part of the assignment, but i get a syntax error for history = model.fit even though the code is correct.

Any help appreciated…
Thanks Andy

Try posting the error maybe it can give us some insight into the error.

Try looking up a few lines to see if there are any mismatched parentheses upstream.

Thank you, yes my code had spelling errors that i couldn’t see for looking earlier :rofl:

HI. I’m getting the same error as discussed in this thread. I looked for parenthesis errors as suggested and they all look right. I also looked for other syntax/spelling errors and have not been able to identify the issue. The one wierd thing that might be a clue is when I tried saying optimizer= tf.keras.optimizers.Adam I got an error saying it did not recongnize tf.keras.optimizers.adam.Adam , when I changed it to optimizer= ‘Adam’ I got no the following error. Can you please point me in the right direction. Thanks for your help.

TypeError Traceback (most recent call last)
in
1 # grader-required-cell
2
----> 3 hist = train_happy_sad_model(gen)

in train_happy_sad_model(train_generator)
37 # You can hardcode up to 20 epochs in the function below but the callback should trigger before 15.
38
—> 39 history = model.fit(x=train_generator,
40 epochs=20,
41 callbacks=[ myCallback]

/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
—> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb

/opt/conda/lib/python3.8/site-packages/keras/callbacks.py in set_model(self, model)
283 model.history = self._history
284 for callback in self.callbacks:
→ 285 callback.set_model(model)
286
287 def _call_batch_hook(self, mode, hook, batch, logs=None):

TypeError: set_model() missing 1 required positional argument: ‘model’

I found the error on my own. no need to reply to this thread