MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Image Modeling with Keras

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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

# Fit the model on a training set
model.fit(____, ____, 
          validation_split=____, 
          epochs=____, batch_size=____)
Edit dan Jalankan Kode