0

hello i am learning to use Tensorflow for machine learning and deep learning, i am following along a video for freeCodeCamp.org, and this is the video i am watching TensorFlow 2.0 Complete Course - Python Neural Networks for Beginners Tutorial .

at 4:15:00 (module 5) the presenter begins training the model on the data set, the training set shown is 50000 in the video. while for me the training set that appears when i execute the following code is only 1563.

note: the video is broken into modules, in each module the presenter explains a certain topic with some coding, there is a link in the description for each code in google colab.

import tensorflow as tf

from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt 

#  LOAD AND SPLIT DATASET
(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()

# Normalize pixel values to be between 0 and 1
train_images, test_images = train_images / 255.0, test_images / 255.0

class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer',
               'dog', 'frog', 'horse', 'ship', 'truck']

model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))

model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))

model.compile(optimizer='adam',
              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
              metrics=['accuracy'])

history = model.fit(train_images, train_labels, epochs=10, 
                    validation_data=(test_images, test_labels))

output:

Epoch 1/10
1563/1563 [==============================] - 25s 16ms/step - loss: 1.5344 - accuracy: 0.4397 - val_loss: 1.2955 - val_accuracy: 0.5370
Epoch 2/10
1563/1563 [==============================] - 26s 16ms/step - loss: 1.1814 - accuracy: 0.5801 - val_loss: 1.1160 - val_accuracy: 0.6018
Epoch 3/10
1563/1563 [==============================] - 26s 17ms/step - loss: 1.0273 - accuracy: 0.6389 - val_loss: 0.9927 - val_accuracy: 0.6508
Epoch 4/10
1563/1563 [==============================] - 26s 16ms/step - loss: 0.9338 - accuracy: 0.6710 - val_loss: 0.9715 - val_accuracy: 0.6585
Epoch 5/10
1563/1563 [==============================] - 26s 17ms/step - loss: 0.8640 - accuracy: 0.6968 - val_loss: 0.9137 - val_accuracy: 0.6807
Epoch 6/10
1563/1563 [==============================] - 26s 17ms/step - loss: 0.8062 - accuracy: 0.7169 - val_loss: 0.8980 - val_accuracy: 0.6893
Epoch 7/10
1563/1563 [==============================] - 23s 15ms/step - loss: 0.7596 - accuracy: 0.7333 - val_loss: 0.8867 - val_accuracy: 0.6946
Epoch 8/10
1563/1563 [==============================] - 25s 16ms/step - loss: 0.7170 - accuracy: 0.7474 - val_loss: 0.8755 - val_accuracy: 0.6990
Epoch 9/10
1563/1563 [==============================] - 25s 16ms/step - loss: 0.6837 - accuracy: 0.7566 - val_loss: 0.8597 - val_accuracy: 0.7104
Epoch 10/10
1563/1563 [==============================] - 24s 16ms/step - loss: 0.6426 - accuracy: 0.7742 - val_loss: 0.8683 - val_accuracy: 0.7063

can someone please tell me why the code doesn't load the full data set and trains the model on it?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
R00
  • 73
  • 1
  • 9

0 Answers0