epoch taking too long,

Question:

I have a good pc with good memory (intel core i7-11th gen, and 16gb of ram)
still each of my epochs are taking about 1,5 hour, is it normal to take this long?

from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM

# define model
model = Sequential()
model.add(LSTM(100, activation='relu', input_shape=(n_input, n_features)))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mse')
 

model.summary()

# fit model
model.fit(generator,epochs=10)

here is the output of the epochs

Asked By: Vinizilin XD

||

Answers:

From your output it seems you have taken a very small batch_size, hence the huge number of iterations. Considering your 16GB of RAM, you should be able to train on larger batches depending on the richness of your data.

You can set your batch size in model.fit as:

model.fit(generator, epochs=10, batch_size=16)

Here the batch_size of 16 is arbitrary, you can choose lesser or more number of batches depending on your system’s capacity.

Or you can also set it in the declaration of the generator like:

datagen = ImageDataGenerator(rescale=1./255)

image_generator = datagen.flow_from_directory(
    images,
    target_size=input_size,
    batch_size=batch_size,
    class_mode=None)
Answered By: Dev Bhuyan
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.