Johnny smith
Johnny smith

Reputation: 309

Keras stops after 1 completed epoch

Trying to run classification on the CIFAR-10 dataset with a simple CNN. However, the model stops after completing the first epoch and doesn't go on to complete all five. Please help.

INPUT:

cifar10 = tf.keras.datasets.cifar10
(train_images, train_labels), (test_images, test_labels) = cifar10.load_data()

import os
import matplotlib.pyplot as plt
import numpy as np
import time
import tensorflow as tf
from tensorflow import keras 
from tensorflow.keras import layers
from tensorflow.keras import models
from tensorflow.keras import optimizers
from tensorflow.keras.applications import VGG16
from tensorflow.keras.preprocessing.image import ImageDataGenerator

model = models.Sequential()

# Convolutional base (feature extractor)
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)))

# Deep feed-forward classifier
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10, activation='softmax'))

model.compile(loss='sparse_categorical_crossentropy', optimizer=optimizers.RMSprop(lr=1e-4), metrics=['acc'])

history = model.fit(
    x=train_images,
    y=train_labels,
    steps_per_epoch=100,
    epochs=5,
    verbose=1,
    validation_data=(test_images, test_labels),
    validation_steps=50)

OUTPUT:

Train on 50000 samples, validate on 10000 samples
Epoch 1/5
50000/50000 [==============================] - 28s 564us/sample - loss: 2.1455 - acc: 0.2945 - val_loss: 2.0011 - val_acc: 0.3038

Upvotes: 3

Views: 2540

Answers (1)

jbasquiat
jbasquiat

Reputation: 101

You should remove steps_per_epoh and validation_steps and use batch_size params.

Upvotes: 5

Related Questions