Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing in

  Enroll Now

Fitting the Model

Let us train the model on the train data.


  • plt.gca() is used to get a reference to the current axes, if you need to change the limits on the y-axis, for example.
  • Use to train the model. We shall pass the X_train, y_train, epochs=30, validation_data=(X_valid, y_valid) as input parameters to the method.

    history =, y_train, epochs=30,
                validation_data=(X_valid, y_valid))

    This might take some time, so go and have a sip of water if you like.

  • Let us now print the parameter history of the history.

  • Let us print the name of the first hidden layer:

    hidden1 = model.layers[1]
  • Let us use get_weights() function to see the trained weights and biases of the hidden1.

    weights, biases = hidden1.get_weights() # getting the weights and biases
    print(weights.shape, weights)
  • Let us visualize the model training history. Here, history.history is a dictionary containing information about the accuracy and loss measures through the epochs.

    Let us store this dictionary as a pandas dataframe and plot the values.

    import pandas as pd
    pd.DataFrame(history.history).plot(figsize=(8, 5))
    plt.gca().set_ylim(0, 1) # setting limits for y-axis

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...