CommencerCommencer gratuitement

A multi-class model

You're going to build a model that predicts who threw which dart only based on where that dart landed! (That is the dart's x and y coordinates on the board.)

This problem is a multi-class classification problem since each dart can only be thrown by one of 4 competitors. So classes/labels are mutually exclusive, and therefore we can build a neuron with as many output as competitors and use the softmax activation function to achieve a total sum of probabilities of 1 over all competitors.

The Sequential model and Dense layers are already imported for you to use.

Cet exercice fait partie du cours

Introduction to Deep Learning with Keras

Afficher le cours

Instructions

  • Instantiate a Sequential model.
  • Add 3 dense layers of 128, 64 and 32 neurons each.
  • Add a final dense layer with as many neurons as competitors.
  • Compile your model using categorical_crossentropy loss.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Instantiate a sequential model
model = ____
  
# Add 3 dense layers of 128, 64 and 32 neurons each
model.add(____(____, input_shape=(2,), activation='relu'))
model.add(____(____, activation='relu'))
model.add(____(____, activation='relu'))
  
# Add a dense layer with as many neurons as competitors
model.add(____(____, activation=____))
  
# Compile your model using categorical_crossentropy loss
model.compile(loss=____,
              optimizer='adam',
              metrics=['accuracy'])
Modifier et exécuter le code