Aan de slagGa gratis aan de slag

Training a CNN to classify clothing types

Before training a neural network it needs to be compiled with the right cost function, using the right optimizer. During compilation, you can also define metrics that the network calculates and reports in every epoch. Model fitting requires a training data set, together with the training labels to the network.

The Conv2D model you built in the previous exercise is available in your workspace.

Deze oefening maakt deel uit van de cursus

Image Modeling with Keras

Cursus bekijken

Oefeninstructies

  • Compile the network using the 'adam' optimizer and the 'categorical_crossentropy' cost function. In the metrics list define that the network to report 'accuracy'.
  • Fit the network on train_data and train_labels. Train for 3 epochs with a batch size of 10 images. In training, set aside 20% of the data as a validation set, using the validation_split keyword argument.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Compile the model 
model.compile(optimizer=____, 
              loss=____, 
              metrics=[____])

# Fit the model on a training set
model.fit(____, ____, 
          validation_split=____, 
          epochs=____, batch_size=____)
Code bewerken en uitvoeren