LoslegenKostenlos loslegen

Batch normalizing a familiar model

Remember the digits dataset you trained in the first exercise of this chapter?

A multi-class classification problem that you solved using softmax and 10 neurons in your output layer.

You will now build a new deeper model consisting of 3 hidden layers of 50 neurons each, using batch normalization in between layers. The kernel_initializer parameter is used to initialize weights in a similar way.

Diese Übung ist Teil des Kurses

Introduction to Deep Learning with Keras

Kurs anzeigen

Anleitung zur Übung

  • Import BatchNormalization from tensorflow.keras layers.
  • Build your deep network model, use 50 neurons for each hidden layer adding batch normalization in between layers.
  • Compile your model with stochastic gradient descent, sgd, as an optimizer.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import batch normalization from keras layers
from tensorflow.____.____ import ____

# Build your deep network
batchnorm_model = ____
batchnorm_model.add(Dense(____, input_shape=(64,), activation='relu', kernel_initializer='normal'))
batchnorm_model.add(____)
batchnorm_model.add(Dense(____, activation='relu', kernel_initializer='normal'))
batchnorm_model.add(____)
batchnorm_model.add(Dense(____, activation='relu', kernel_initializer='normal'))
batchnorm_model.add(____)
batchnorm_model.add(Dense(10, activation='softmax', kernel_initializer='normal'))

# Compile your model with sgd
batchnorm_model.compile(optimizer=____, loss='categorical_crossentropy', metrics=['accuracy'])
Code bearbeiten und ausführen