liveBook · Manning

Keras

As explained in Fight Fraud with Machine Learning

Keras is a high-level deep-learning API for constructing and training neural networks, integrated into TensorFlow as tf.keras.

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

How Fight Fraud with Machine Learning covers it

How deep it goes
Explains architecture, compilation, and model inspection through runnable code without descending into framework internals.
Examples
Uses a Sequential sigmoid network with three hidden layers, Adam optimization, binary cross-entropy, accuracy, and a 271-parameter summary.
What you can do after
Build it from scratch with tf.keras by defining layers, compiling training settings, and inspecting the resulting model.
How it connects
Connects Keras with TensorFlow, neural-network layers, optimizers, loss functions, evaluation metrics, and PyTorch.

Also explained in

Compare how 7 books explain Keras →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fight Fraud with Machine Learning. The section links point to the parts of the book it draws on.