[英]Keras 2 fit_generator UserWarning: `steps_per_epoch` is not the same as the Keras 1 argument `samples_per_epoch`
我在Jupyter Notebook中使用Keras 2.0.8和Python 3內核。 我的后端是TensorFlow 1.3,我正在Mac上開發。
每當我使用fit_generator()時,我都會收到以下警告:
/Users/username/anaconda/envs/tensorflow/lib/python3.6/site-packages/ipykernel/ main .py:5:UserWarning:
steps_per_epoch
2參數steps_per_epoch
的語義與steps_per_epoch
1參數samples_per_epoch
。steps_per_epoch
是每個時期從生成器中繪制的批次數。 基本上是steps_per_epoch = samples_per_epoch / batch_size。 類似地,nb_val_samples
- >validation_steps
和val_samples
- >steps
參數已更改。 相應地更新方法調用。 /Users/username/anaconda/envs/tensorflow/lib/python3.6/site-packages/ipykernel/ main .py:5:UserWarning:更新你對fit_generator
調用:fit_generator(<keras.pre..., steps_per_epoch=60000, validation_data=<keras.pre..., epochs=1, validation_steps=10000)
下面是我的模型的代碼(簡單的MNIST線性分類器,但我對我使用的每個模型都收到此警告):
model = Sequential([
Lambda(normalize_input, input_shape=(1, 28, 28)),
Flatten(),
Dense(10, activation='softmax')
])
model.compile(Adam(),
loss='categorical_crossentropy',
metrics=['accuracy'])
這是我的fit_generator()調用:
model.fit_generator(batches,
steps_per_epoch=steps_per_epoch,
nb_epoch=1,
validation_data=test_batches,
nb_val_samples=test_batches.n)
我理解這個警告告訴我的是什么。 在我的情況下,這不是問題。 我怎么能擺脫它?
如果函數調用中存在任何Keras 1.0關鍵字,則會出現此警告。 更新替換您的函數調用nb_epoch
與epochs
,與nb_val_samples
與validation_steps
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.