Google Colab requires making shapes compatible to run the model as it already mentioned in similar topic and here python - ValueError: Shapes (None, 1) and (None, 3) are incompatible - Stack Overflow
So, tried in the first submission to use import to_categorical from keras utils and gave an error with grader
There was a problem compiling the code from your notebook. Details:
cannot import name ‘to_categorical’ from ‘keras.utils’ (/opt/conda/lib/python3.7/site-packages/keras/utils/init.py)
then changed synatx to to
training_labels_encoded = tf.keras.utils.to_categorical(training_labels, num_classes=num_classes) validation_labels_encoded = tf.keras.utils.to_categorical(validation_labels, num_classes=num_classes)
and getting Coursera grader error bellow while in the same time Google Colab all works well and the model achieves all required benchmarks
All tests passed for parse_data_from_input! All tests passed for train_val_generators! Details of failed tests for create_model Failed test case: your model could not be used for inference. Details shown in ‘got’ value below:. Expected: no exceptions, but got: in user code: File “/opt/conda/lib/python3.7/site-packages/keras/engine/training.py”, line 1366, in test_function * return step_function(self, iterator) File “/opt/conda/lib/python3.7/site-packages/keras/engine/training.py”, line 1356, in step_function ** outputs = model.distribute_strategy.run(run_step, args=(data,)) File “/opt/conda/lib/python3.7/site-packages/keras/engine/training.py”, line 1349, in run_step ** outputs = model.test_step(data) File “/opt/conda/lib/python3.7/site-packages/keras/engine/training.py”, line 1306, in test_step y, y_pred, sample_weight, regularization_losses=self.losses) File “/opt/conda/lib/python3.7/site-packages/keras/engine/compile_utils.py”, line 201, in call loss_value = loss_obj(y_t, y_p, sample_weight=sw) File “/opt/conda/lib/python3.7/site-packages/keras/losses.py”, line 141, in call losses = call_fn(y_true, y_pred) File “/opt/conda/lib/python3.7/site-packages/keras/losses.py”, line 245, in call ** return ag_fn(y_true, y_pred, **self._fn_kwargs) File “/opt/conda/lib/python3.7/site-packages/keras/losses.py”, line 1665, in categorical_crossentropy y_true, y_pred, from_logits=from_logits, axis=axis) File “/opt/conda/lib/python3.7/site-packages/keras/backend.py”, line 4994, in categorical_crossentropy target.shape.assert_is_compatible_with(output.shape) ValueError: Shapes (None, 1) and (None, 24) are incompatible .
pls help with the issue if somebody knows a workaround that will satisfy both model training in Google Colab and Coursera grader