I have tried refreshing my workspace, and I retyped/reran all the prior code windows in a fresh notebook. I have made NO modifications outside the designated sections. All unit tests pass, and all output shapes match the expected values. One other note - I tried submitting to the grader to see if I would get any useful feedback - I get zero on all sections with the message, “There was a problem compiling the code from your notebook. Details:
invalid syntax (, line 497)” I’ve never submitted before without completing the entire assignment, so I’m not sure if it is that or a real/related issue.
Here is the snippet from the train step error:
TypeError: in user code:
File "/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py", line 1338, in train_function *
return step_function(self, iterator)
File "/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py", line 1322, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py", line 1303, in run_step **
outputs = model.train_step(data)
File "/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py", line 1081, in train_step
loss = self.compute_loss(x, y, y_pred, sample_weight)
File "/usr/local/lib/python3.8/dist-packages/keras/src/engine/training.py", line 1139, in compute_loss
return self.compiled_loss(
File "/usr/local/lib/python3.8/dist-packages/keras/src/engine/compile_utils.py", line 317, in __call__
self._total_loss_mean.update_state(
File "/usr/local/lib/python3.8/dist-packages/keras/src/utils/metrics_utils.py", line 77, in decorated
update_op = update_state_fn(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/keras/src/metrics/base_metric.py", line 140, in update_state_fn
return ag_update_state(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/keras/src/metrics/base_metric.py", line 509, in update_state **
sample_weight = tf.__internal__.ops.broadcast_weights(
File "/usr/local/lib/python3.8/dist-packages/keras/src/engine/keras_tensor.py", line 285, in __array__
raise TypeError(
TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='Placeholder:0', description="created by layer 'tf.cast_23'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
Any help would be greatly appeciated.
Thanks!