Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
Let us define the model for the classification of data set B that we have created previously.
Later, let us also examine the classification of B set by using the trained weights of model A.
Create a keras neural network as follows:
Add keras.layers.Flatten
to flatten the input image to the model.
Add 5 dense layers with n_hidden
number of neurons and selu
activation function.
Add a final dense layer with 1 neuron and softmax
activation function(for classifying 2 classes of data).
model_B = keras.models.Sequential()
model_B.add(keras.layers.Flatten(input_shape=[28, 28]))
for n_hidden in (300, 100, 50, 50, 50):
model_B.add(keras.layers.Dense(n_hidden, activation="selu"))
model_B.add(keras.layers.Dense(1, activation="softmax"))
Define the compiling part of the model:
Set "binary_crossentropy"
as loss, as this is binary classification among sandals and shirts.
Set keras.optimizers.SGD(lr=1e-3)
as optimizer.
model_B.compile(loss= << your code comes here >>,
optimizer= << your code comes here >>,
metrics=["accuracy"])
Now train model_B
on X_train_B
and y_train_B
for 5 epochs , and validation_data=(X_valid_B, y_valid_B)
using model.fit
.
history = << your code comes here >>(X_train_B, y_train_B, epochs=5,
validation_data=(X_valid_B, y_valid_B))
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...