我正在使用Tensorflow Hub进行二进制文本分类。
fit
当我使用fit_generator
命令拟合模型时,可以将历元设置为所需的最大值。当我使用# Trains as expected
model.fit(x_train, y_train, epochs=100)
# Errors during training with
# 'Your dataset iterator ran out of data; interrupting training.
# Make sure that your iterator can generate at least `steps_per_epoch * epochs`
# batches (in this case, 600 batches).'
model.fit_generator(my_iterator(x_train, y_train), epochs=100, steps_per_epoch=len(x_train))
方法时,似乎每个数据点只能使用一次。
<?php
$_SESSION = array();
session_destroy();
header("Location: index.php?p=main");
alert("You have been successfully logged out!");
如何正确设置迭代器以使用生成器进行训练?
答案 0 :(得分:0)
“预计生成器将无限期地循环其数据”。因此需要将我的迭代器定义为:
def my_iterator(x, y):
while True:
for _x, _y in zip(x, y):
yield np.array([_x]), np.array([_y])