如何在为训练提供tensorflow会话时将numpy数组转换为批处理

时间:2017-12-04 18:22:21

标签: python numpy tensorflow neural-network

数据集很大,如何使用批量大小为100的Feed数据。 x_u is image data and y_u is labels x_u, y_u are of sizes 2000000 with tf.Session() as sess: #writer = tf.summary.FileWriter("output", sess.graph) sess.run(tf.global_variables_initializer()) for i in range(3): train_accuracy = accuracy.eval(feed_dict={x: x_u, y_: y_u, keep_prob: 1.0}) print('step %d, training accuracy: %g', (i, train_accuracy)) train_step.run(feed_dict={x: x_u, y_: y_u, keep_prob:0.5})

1 个答案:

答案 0 :(得分:0)

BATCH_SIZE = 100
for offset in range(0, len(y_u), BATCH_SIZE):
    batch_x = x_u[offset: offset + BATCH_SIZE]
    batch_y = y_u[offset: offset + BATCH_SIZE]

    # Feed batch_x an batch_y