Keras is a high-level deep-learning API integrated into TensorFlow as tf.keras. It builds, trains, evaluates, and inspects neural networks with concise Python code. section 4.2.2
A compact binary-classification network
A Sequential model can define an eight-feature input, three nine-unit sigmoid hidden layers, and a sigmoid output, then compile with Adam, binary cross-entropy, and accuracy. Its summary reports 271 trainable parameters. section 4.2.2
import tensorflow as tf
# Define the architecture of the neural network
input_size = 8
hidden_layer_sizes = [9, 9, 9]
output_size = 1
# Initialize a Sequential model
model = tf.keras.Sequential()
# Add the input layer
model.add(tf.keras.layers.InputLayer(input_shape=(input_size,)))
# Add three hidden layers with sigmoid activation
for layer_size in hidden_layer_sizes:
model.add(tf.keras.layers.Dense(layer_size, activation='sigmoid'))
# Add the output layer with sigmoid activation
model.add(tf.keras.layers.Dense(output_size, activation='sigmoid'))
# Compile the model
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
# Print the model summary
model.summary()
Inspect the complete tf.keras listing for layer construction, compilation, and model summarization. section 4.2.2






