只需使用相同的「種子」關鍵字參數值,例如對於標籤和數據,功能 tf.random_shuffle中的seed = 8。
ipdb> my_data = tf.convert_to_tensor([[1,1], [2,2], [3,3], [4,4],
[5,5], [6,6], [7,7], [8,8]])
ipdb> my_labels = tf.convert_to_tensor([1,2,3,4,5,6,7,8])
ipdb> sess.run(tf.random_shuffle(my_data, seed=8))
array([[5, 5],
[3, 3],
[1, 1],
[7, 7],
[2, 2],
[8, 8],
[4, 4],
[6, 6]], dtype=int32)
ipdb> sess.run(tf.random_shuffle(my_labels, seed=8))
array([5, 3, 1, 7, 2, 8, 4, 6], dtype=int32)
編輯: 如果你需要在運行時,在批次,也就是說,將隨機但differendly洗牌隨機洗牌,你可以使用這樣的伎倆:
# each time shuffling pattern will be differend
# for now, it works
indicies = tf.random_shuffle(tf.range(8))
params = tf.convert_to_tensor([111, 222, 333, 444, 555, 666, 777, 888])
sess.run(tf.add(tf.gather(params, indicies), tf.gather(params, indicies) * 1000))
> array([555555, 444444, 666666, 222222, 111111, 888888, 333333, 777777], dtype=int32)
由相同的數字
號顯示,收集< - 物業採取相同的種子值
是否要通過批量輸入佔位符提供圖像? –
我不認爲我需要佔位符,因爲我已經加載了'tf.image.decode_png()'並在會話中對其進行了評估(如果需要,我可以發佈代碼)。但是,我需要使用批次進行培訓。 –
你想要這樣的東西嗎? https://stackoverflow.com/questions/34340489/tensorflow-read-images-with-labels –