epoch taking too long,

huangapple go评论67阅读模式
英文:

epoch taking too long,

问题

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 hours, is it normal to take this long?

我有一台性能不错的电脑,配备有英特尔第11代核心i7处理器和16GB内存,但每个训练周期大约需要1.5小时,这个时间是否正常?

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

# 定义模型
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()

# 训练模型
model.fit(generator, epochs=10)

epoch taking too long,

英文:

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)

epoch taking too long,

答案1

得分: 2

从您的输出来看,似乎您选择了非常小的批次大小,因此迭代次数很多。考虑到您的16GB内存,您应该能够根据数据的丰富程度选择更大的批次进行训练。

您可以在model.fit中设置批次大小:

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

这里的批次大小为16是任意的,您可以根据系统容量选择更少或更多的批次。

或者,您也可以在生成器的声明中设置批次大小,如下所示:

datagen = ImageDataGenerator(rescale=1./255)

image_generator = datagen.flow_from_directory(
    images,
    target_size=input_size,
    batch_size=batch_size,
    class_mode=None)
英文:

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)

huangapple
  • 本文由 发表于 2023年3月4日 06:36:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75632413.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定