Hello everyone, for the second assignment of the first week, happyModel => I’ve passed all the tests and I just wanted to try something and using convet_to_one_hot(Y_train_orig, 2) because we have to class (smile or not) but everything is ok before I get to .fit() part and I get this weird error.
and this my changes:
This is a binary classification, so the logits (the output before sigmoid) are a single value. So if you’re going to represent the labels as one hot vectors with two elements, how can you compute the cost function if the outputs are single values?
You’ll need to use softmax as the output function and categorical cross entropy as the loss instead of sigmoid and binary cross entropy if you want to do it that way, right?
1 Like
Hello Paulin, yes you’re right the output of my network was of shape (None, 1), and because I choose the last layer (output layer) has one unit. so if I want to use one_hot_encoding I need to increase the number of units to match up exactly to the number of classes (here 0 or 1) and so;
tf.keras.layers.Dense(2, activation=“sigmoid”)
and it gives me the right answer.
thank you
Interesting. I would not have thought of doing it that way. I would have treated it as a multi-class classification with 2 classes and used softmax as the output. Also note that they tell us to use from_logits = True here, so with your implementation you end up applying sigmoid twice. Applying sigmoid to a value that is already between 0 and 1 constrains your answers quite a bit. But apparently the training can still work in that scenario.
1 Like
Again Thank you, Paulin. You helped me a lot throughout this specialization.
you’re a great mentor.