Neural Networks TensorFlow
Keras fit

TensorFlow / Keras

TensorFlow 2 defaults to eager execution and bundles Keras as tf.keras. The Sequential API stacks layers linearly; the Functional API builds arbitrary DAGs (multi-input, skip connections). You compile() with optimizer, loss, and metrics, then fit() on NumPy arrays or tf.data.Dataset. Callbacks handle checkpointing, early stopping, and learning-rate schedules.

model.fit tf.data SavedModel callbacks

Sequential Model

Small classifier
import tensorflow as tf

model = tf.keras.Sequential([
    tf.keras.layers.Flatten(input_shape=(28, 28)),
    tf.keras.layers.Dense(128, activation="relu"),
    tf.keras.layers.Dense(10, activation="softmax"),
])
model.compile(
    optimizer="adam",
    loss="sparse_categorical_crossentropy",
    metrics=["accuracy"],
)
model.fit(x_train, y_train, epochs=5, validation_split=0.1)

tf.data & Production

tf.data.Dataset pipelines prefetch and parallelize I/O—important for large files or TPU training. For deployment, SavedModel captures graph and weights for TensorFlow Serving, TF Lite, or browser via TF.js.

PyTorch vs TensorFlow is often a team and deployment choice; both are first-class for research and production today.

Summary

  • Keras: build with Sequential or Functional API; train with compile + fit.
  • Use callbacks for early stopping, ModelCheckpoint, TensorBoard.
  • tf.data scales input pipelines; SavedModel exports for serving.
  • Next: hands-on projects to consolidate skills.

Apply what you learned in guided hands-on NN projects.