Project - Working with Custom Loss Function

4 / 6

Building the Network

We shall now build the classification network, with a hidden layer(with 30 neurons and selu activation function) and an output layer( with 1 neuron since we have to predict only one value).

We shall also specify the loss function we have defined - the huber_fn and the optimizer to use, while compiling.

Note:

  • kernel_initializer defines the way to set the initial random weights of Keras layers.
INSTRUCTIONS
  • Set "selu" as the activation and "lecun_normal" as the kernel_initializer for the following model.

    model = keras.models.Sequential([
        keras.layers.Dense(30, activation=<< your code comes here >>, 
           kernel_initializer=<< your code comes here >>, 
           input_shape=X_train.shape[1:]),
        keras.layers.Dense(1),
    ])
    
  • Compile the model using compile.

    • Set loss to be huber_fn which is the custom loss function we defined

    • We will be using "nadam" optimizer and "mae" metric.

      model.<< your code comes here >>(loss=<< your code comes here >>, optimizer="nadam", metrics=["mae"])
      
Get Hint See Answer


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

Loading comments...