Multiclass classification problems
In this exercise, we expand beyond binary classification to cover multiclass problems. A multiclass problem has targets that can take on three or more values. In the credit card dataset, the education variable can take on 6 different values, each corresponding to a different level of education. We will use that as our target in this exercise and will also expand the feature set from 3 to 10 columns.
As in the previous problem, you will define an input layer, dense layers, and an output layer. You will also print the untrained model's predictions, which are probabilities assigned to the classes. The tensor of features has been loaded and is available as borrower_features
. Additionally, the constant()
, float32
, and keras.layers.Dense()
operations are available.
This exercise is part of the course
Introduction to TensorFlow in Python
Exercise instructions
- Define the input layer as a 32-bit constant tensor using
borrower_features
. - Set the first dense layer to have 10 output nodes and a
sigmoid
activation function. - Set the second dense layer to have 8 output nodes and a rectified linear unit activation function.
- Set the output layer to have 6 output nodes and the appropriate activation function.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Construct input layer from borrower features
inputs = ____
# Define first dense layer
dense1 = keras.layers.Dense(____, activation='____')(inputs)
# Define second dense layer
dense2 = ____
# Define output layer
outputs = ____
# Print first five predictions
print(outputs.numpy()[:5])