[英]Tensorflow: Get color image data based on file names rather than directories
[英]Using data from a file rather than random data in Tensorflow
我正在嘗試使用python在Tensorflow中模擬Conway的生活游戲,並且已成功實現了使用以下代碼通過隨機初始2d數組模擬游戲的代碼
tf.random_uniform(shape, minval=0, maxval=2, dtype=tf.int32)
現在,我希望使用2d格式的具有0和1的csv文件從0和1的數組初始化2d矩陣。 我應該如何初始化Conway游戲的初始棋盤?
到目前為止,我的代碼:
shape = (5,5)
initial_board = tf.random_uniform(shape, minval=0, maxval=2, dtype=tf.int32)
with tf.Session() as session:
X = session.run(initial_board)
X是我的起始二維數組。
有幾種方法,例如,請參見下文:
import tensorflow as tf
initial_board = tf.constant([[1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 0, 1, 0, 0], [1, 0, 0, 0, 1]], dtype=tf.int32)
with tf.Session() as session:
X = session.run(initial_board)
print X
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.