Hello,

After completing this section of Course 4 Week 2 Assignment 2, I noticed the the class_names are alpaca and not alpaca. But while creating the alpaca model, we did not mention anywhere about the classes. So I was confused as how did we input to the model mentioning the alpaca or non-alpaca classes?
I have this doubt especially because in the parameters list, we are not passing any dataset of the alpaca model. Rather, we use the generally available imageNet dataset.
Please clarify.
The number of classes is represented by neurons of the output layer. For an N-class classification:
- When N == 2, we need only 1 neuron at the output layer.
- When N > 2, we need N neurons at the output layer.
A NN understands only numeric values. Assigning human readable names to class labels is done for our understanding. The mapping between a label as integer and the corresponding label string is done when preparing the dataset.
1 Like
Hi,
Thanks for the reply, but Iām afraid I still have a doubt. What I need to know is in which part of the code is the class names āalpacaā and ānot alpacaā defined?
You can see that earlier in the notebook. There is the array class_names
which is extracted from an attribute of the training dataset. They print the contents of class_names
for you. If you modify the logic of the section that displays some of the images to show the actual label values, youāll see that the way the data is labeled is that 0 (False) means āalpacaā and 1 (True) means ānot alpacaā. So the real place where this is defined is not in the code but in the training data.
Then we train the model with those labels. As Balaji points out, itās a binary classification, so we only need one output neuron.
1 Like
See image_dataset_from_directory. The folder names inside the dataset
directory become class names.
2 Likes
Oh yes. I got it! Thanks a lot for your support Balaji and Paul! 