C4_W2_Alpaca Model

Hello !

I have a question regarding the part where we visualizing some images from the dataset.

There is a misty line: class_names = train_dataset.class_names, which outputs the list of classes.
what is .class_names there?
I checked help on train_dataset, there is no such method as class_names. However there is such argument for the image_dataset_from_directory. Then I don’t understand why I can’t do train_dataset.subset or train_dataset.batch_size it says that there is no such attribute.

So my question, what is the .class_names ?

Thanks

Hi Viktoriia,

.class_names is a list attribute of the tf.data.Dataset returned by
tf.keras.preprocessing.image_dataset_from_directory.

Have a look here (class_names is not explicitly mentioned as a returned attribute):

Hello @reinoudbosch !

Thanks for the reply.

Then how can I possibly know that it exists if when I read help it is not explicitly mentioned ?

Is there other list attributes for tf.data.Dataset not mentioned ?

Hi Viktoriia,

You can see the properties of train_dataset if you create a new cell below the cell in which it is defined and type the following:

train_dataset.__dict__

If you just want to see the keys you can use

print(train_dataset.__dict__.keys())

1 Like