-3
我在Google上搜索了很多,我找不到批量培训模型的例子。在Tensorflow数据集中构建的mnist具有mnist.train.next_batch(BATCH_SIZE)
函数,我需要这样的函数将我的数据集分成批次并为每次迭代加载下一批。在Tensorflow中批量训练模型的快速示例?
我在Google上搜索了很多,我找不到批量培训模型的例子。在Tensorflow数据集中构建的mnist具有mnist.train.next_batch(BATCH_SIZE)
函数,我需要这样的函数将我的数据集分成批次并为每次迭代加载下一批。在Tensorflow中批量训练模型的快速示例?
您可以分割你的列车数据如下:在每次迭代
#Generate a random batch of 200 samples
rand_index = np.random.choice(len(x_data), size=200)
rand_x = x_data[rand_index]
rand_y = y_data[rand_index]
然后,您可以通过批量培养一批。
for i in range(1000):
for u in range(number_of_batches):
sess.run(train, feed_dict={x: rand_x.....})
类似的东西会工作。
目前我的训练方式相同,但对于每个模型,我需要计算number_of_batches和no。手动进行每次迭代的批次,并且对于复杂模型而言, –
next_batch的源代码是免费的。您当然可以重复使用该代码用于您的代码。 – Wontonimo