使用 Tensorflow (MobileNet) 进行迁移学习

Transfer Learning with Tensorflow (MobileNet)

在迁移学习中,我认为我的 model.fit_generator 进入了无限循环。我不知道怎么做。这是我的 Colab 笔记本 link https://colab.research.google.com/drive/1o9GNCQdMeh4HZdiZ5QAjiDDkixn-OsXx

Here is the image of model.fit_generator

如果按如下方式更新最后一行,则 5 个纪元大约需要 40 秒。

来自

model.fit_generator(train_generator, epochs=5, validation_data=valid_generator)

model.fit_generator(train_generator, epochs=5, steps_per_epoch=len(train_generator), validation_data=valid_generator, validation_steps=len(valid_generator))

请检查当 model.fit 的输入是生成器时预期的描述。因此,当 'steps_per_epoch' 为 None 时,epoch 将 运行 直到输入数据集耗尽。因此,如果您的数据集是无限重复的数据集,则生成器 运行 无限地生成。

steps_per_epoch: Integer or None. Total number of steps (batches of samples) before declaring one epoch finished and starting the next epoch. When training with input tensors such as TensorFlow data tensors, the default None is equal to the number of samples in your dataset divided by the batch size, or 1 if that cannot be determined. If x is a tf.data dataset, and 'steps_per_epoch' is None, the epoch will run until the input dataset is exhausted. When passing an infinitely repeating dataset, you must specify the steps_per_epoch argument. This argument is not supported with array inputs.