2.1 Hyperparameters

In [5]:
# Hyperparameters
training_epochs = 10 # Total number of training epochs
learning_rate = 0.01 # The learning rate
momentum = 0.9

2.2 Creating a model

In [6]:
# create a model
def create_model():
    model = tf.keras.Sequential()
    # Hidden layers
    model.add(tf.keras.layers.Dense(12, input_dim=2, activation='relu'))
    model.add(tf.keras.layers.Dense(6, activation='relu'))
    # Output layer
    model.add(tf.keras.layers.Dense(1, activation='sigmoid'))

    # Compile a model
    model.compile(loss='binary_crossentropy', 
                optimizer=tf.keras.optimizers.SGD(learning_rate, momentum),
                metrics=['accuracy'])
    return model
model = create_model()
model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense (Dense)                (None, 12)                36        
_________________________________________________________________
dense_1 (Dense)              (None, 6)                 78        
_________________________________________________________________
dense_2 (Dense)              (None, 1)                 7         
=================================================================
Total params: 121
Trainable params: 121
Non-trainable params: 0
_________________________________________________________________