Get startedGet started for free

Training with multiple labels

An output of your multi-label model could look like this: [0.76 , 0.99 , 0.66 ]. If we round up probabilities higher than 0.5, this observation will be classified as containing all 3 possible labels [1,1,1]. For this particular problem, this would mean watering all 3 parcels in your farm is the right thing to do, according to the network, given the input sensor measurements.

You will now train and predict with the model you just built. sensors_train, parcels_train, sensors_test and parcels_test are already loaded for you to use.

Let's see how well your intelligent machine performs!

This exercise is part of the course

Introduction to Deep Learning with Keras

View Course

Exercise instructions

  • Train the model for 100 epochs using a validation_split of 0.2.
  • Predict with your model using the test data.
  • Round up your preds with np.round().
  • Evaluate your model's accuracy on the test data.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Train for 100 epochs using a validation split of 0.2
____.____(____, ____, epochs = ____, validation_split = ____)

# Predict on sensors_test and round up the predictions
preds = ____.____(____)
preds_rounded = np.round(____)

# Print rounded preds
print('Rounded Predictions: \n', preds_rounded)

# Evaluate your model's accuracy on the test data
accuracy = model.evaluate(____, ____)[1]

# Print accuracy
print('Accuracy:', accuracy)
Edit and Run Code