Keras | Sheetly Cheat Sheet

Last Updated: November 21, 2025

Keras

High-level neural networks API

Core Components

Item Description
Sequential Linear stack of layers
Functional API Complex model architectures
Layer Building block of models
Model Training and inference
Callback Training hooks
Optimizer Training algorithms

Model Example

from tensorflow import keras
from tensorflow.keras import layers

# Sequential model
model = keras.Sequential([
    layers.Dense(128, activation='relu', input_shape=(784,)),
    layers.Dropout(0.2),
    layers.Dense(10, activation='softmax')
])

model.compile(
    optimizer='adam',
    loss='sparse_categorical_crossentropy',
    metrics=['accuracy']
)

# Train
history = model.fit(
    x_train, y_train,
    epochs=10,
    validation_split=0.2,
    batch_size=32
)

# Evaluate
model.evaluate(x_test, y_test)

Common Layers

Item Description
Dense Fully connected layer
Conv2D 2D convolution
MaxPooling2D Max pooling
Dropout Regularization
LSTM Recurrent layer
BatchNormalization Normalize activations

Best Practices

  • Use functional API for complex architectures
  • Add callbacks for early stopping
  • Use validation split to monitor overfitting
  • Save best model with ModelCheckpoint

💡 Pro Tips

Quick Reference

Keras is now integrated into TensorFlow 2.0+

← Back to Data Science & ML | Browse all categories | View all cheat sheets