level 1
今天正好也纠结这个问题,然后上网查了一下。
image_batch, label_batch = tf.train.shuffle_batch([img, label], batch_size=batchSize, capacity=capacity,
min_after_dequeue=min_after_dequeue)
这是个得到batch的函数,其中的allow_smaller_final_batch可选。
True就是允许最后得到的batch小于batchsize,FALSE就丢弃了这部分数据。
2018年09月26日 06点09分
3
允许batchsize小于batchsize感觉就有另一个问题,如果网络中定义了batchsize这一维是不是就不匹配了,不过我现在改用dataset来读取数据了,这个问题我也直接回避了
2018年09月26日 07点09分
level 1
def imageToTensor(file):
binary = tf.gfile.FastGFile(file, 'rb').read()
return tf.image.decode_image(binary)
def getTrainData(start, end):
data = []
label = []
for i in range(start, end + 1, 1):
data.append(imageToTensor('cat/' + str(i + 1) + '.png'))
label.append(tf.constant(1))
data.append(imageToTensor('dog/' + str(i + 1) + '.png'))
label.append(tf.constant(0))
return data, label
(data, label) = getTrainData(1, 170000)
请问这样读数据内存不够,怎么拆开来?
2018年09月27日 12点09分
4