创建Session
1 | import tensorflow as tf |
普通Session
1 | sess = tf.Session() |
交互式Session
1 | import tensorflow as tf |
在sess内执行op
方法1
sess.run(tf.global_variables_initializer())
sess.run(op)
代码示例
1 | sess.run(tf.global_variables_initializer()) |
方法2
tf.global_variables_initializer().run()
sess.run(op)
op.eval()
代码示例
1 | tf.global_variables_initializer().run() |
新op添加到默认图上
1 | import tensorflow as tf |
查看shape
1 | import tensorflow as tf |
常用function
tf.stack
1 | import tensorflow as tf |
tf.ones_like, tf.multiply
tf.ones_like返回与输入tensor具有相同shape的tensor
1 | import tensorflow as tf |
列出graph中所有操作
1 | import tensorflow as tf |