两种运行计算图的方式
import tensorflow as tf
a=tf.constant([1,2,3],name='a')
c=a+1
####1
with tf.Session as sess:
print(sess.run(c))
####2
sess=tf.Session()
with sess.as_default():
print(c.eval())
tensorflow中的一些接口:
tf.Graph()
tf.Graph.device()
tf.Graph.as_default()
tf.Session()
tf.Session.run()
tf.Session.as_default()
tf.constant()
tf.variable()
tf.get_variable()
tf.placeholder()
tf.train()
tf.train.GradientDescentOptimizer
tf.train.Saver
tf.nn()
本文介绍了使用TensorFlow运行计算图的两种主要方式:通过Session的run方法和使用eval方法。此外,还列举了TensorFlow中常用的一些接口,如Graph、Session、constant、variable等,为读者提供了TensorFlow的基本操作指南。
2万+

被折叠的 条评论
为什么被折叠?



