DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 967,911 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Mohamed Bakrey
Mohamed Bakrey

Posted on

Introduction to TensorFlow 2

Hello TensorFlow!

How to import tensorflow.

# Import TensorFlow
import tensorflow as tf

Loading the image

print('Loading data...\n')
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
print('MNIST dataset loaded.\n')

creat the model

x_train = x_train/255.
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(16, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])

make compile for the model

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

Make Fit foe the model

print('Training model...\n')
model.fit(x_train, y_train, epochs=3, batch_size=32)
print('Model trained successfully!')

Latest comments (0)

๐ŸŒ–๐ŸŒ—๐ŸŒ˜ Turn on dark mode in Settings