09.05.2023 Views

pdfcoffee

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Regression

The Estimator outputs the log probabilities (logits), the softmax probabilities for the

ten classes, and the corresponding label:

Let us build our model.

1. The first step is as always importing the modules needed:

# TensorFlow and tf.keras

import tensorflow as tf

from tensorflow import keras

# Helper libraries

import numpy as np

import matplotlib.pyplot as plt

print(tf.__version__)

2. We take the input data of MNIST from the tensorflow.keras dataset:

# Load training and eval data

((train_data, train_labels),

(eval_data, eval_labels)) = tf.keras.datasets.mnist.load_data()

3. Next, we preprocess the data:

train_data = train_data/np.float32(255)

train_labels = train_labels.astype(np.int32)

eval_data = eval_data/np.float32(255)

eval_labels = eval_labels.astype(np.int32)

[ 104 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!