First classifier in minutes
Build a tf.keras model for MNIST, train for 1 epoch, and report accuracy. Keep code under 25 lines.
Data / Knowledge library
an open-source framework for machine learning workflows
TensorFlow helps teams build, train, and deploy machine learning models across laptops, cloud clusters, browsers, and mobile/edge devices using one core framework.
Google open-sourced TensorFlow in 2015 as the successor to DistBelief-era internal tooling. TensorFlow 1.x emphasized static graphs and session-based execution. TensorFlow 2.0 (2019) made eager execution and Keras-style APIs the default for usability. TensorFlow grew into a broader ecosystem: TensorBoard (tracking), TFX (pipelines), and TFLite (edge inference).
Work through these exercises in order. Try the task before opening a reference.
Build a tf.keras model for MNIST, train for 1 epoch, and report accuracy. Keep code under 25 lines.
Replace raw NumPy feeding with tf.data.Dataset batching, shuffling, and prefetching. Compare training time.
Train a small model using tf.GradientTape instead of model.fit, and log loss every 100 steps.
Convert a trained model to TensorFlow Lite, apply post-training quantization, and measure model size change.
In 5 bullet points, explain eager execution, tf.function, tensors, gradients, and model export.
A high-precision electronics manufacturer producing micro-components.
Manual visual inspection of micro-components is slow, prone to human fatigue, and results in inconsistent quality control standards across shifts.
Implementing a computer vision pipeline using TensorFlow Keras to classify component images as 'pass' or 'fail' based on structural integrity, enabling real-time automated sorting.
The flow of image data through the TensorFlow-based classification system.
Captures raw component images
Preprocesses and batches images
Classifies image as Pass/Fail
Physical actuator for output
This maps to the solution by defining a neural network architecture capable of learning the visual features required to distinguish between defective and non-defective components.
import tensorflow as tf
# Define a simple model for binary classification
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(128, 128)), # Input image size
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(1, activation='sigmoid') # Binary output: Pass/Fail
])
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])A consistent, high-speed inspection process that reduces human error and standardizes quality thresholds across all production lines.
The model may suffer from 'concept drift' if manufacturing processes change, requiring periodic retraining; monitor this by tracking classification accuracy over time against manual audits.