Hi Everyone,
I’m trying to do the assignment for the course #2 week #4
I am quire confused about the setup.
the data shape requirements are:
Expected Output:
Training images has shape: (27455, 28, 28) and dtype: float64
Training labels has shape: (27455,) and dtype: float64
Validation images has shape: (7172, 28, 28) and dtype: float64
Validation labels has shape: (7172,) and dtype: float64
the output label seems to be defined as actual letter ‘a’ - ‘z’ (or the number 1-26)
I can’t use that as is for defining the network.
I tried to use the one hot encoding for 26 classes for training and validation properly, used that as the last layer in the network:
…
training_categorical_labels = to_categorical(training_labels, num_classes=26)
…
tf.keras.layers.Dense(26, activation=‘softmax’)
…
[snippet removed by mentor]
as a result, I get decent training/validation accuracy, but then in the grader I get:
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, 26) are incompatible
is there some actual error in the setup, or should I use some custom/advanced code/layers?