YouTip LogoYouTip

TensorFlow Tutorial - Getting Started

TensorFlow Basics

import tensorflow as tf

model = tf.keras.Sequential([
    tf.keras.layers.Dense(128, activation="relu"),
    tf.keras.layers.Dense(10, activation="softmax")
])

model.compile(optimizer="adam", loss="sparse_categorical_crossentropy")

Training

(x_train, y_train), _ = tf.keras.datasets.mnist.load_data()
x_train = x_train.reshape(-1, 784) / 255.0
model.fit(x_train, y_train, epochs=5)

Summary

  • Sequential API stacks layers
  • model.fit() trains the model
← PyTorch Tutorial - Getting StaMatplotlib Tutorial - Charts β†’