![](/img/trans.png)
[英]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.