tensorflow 学习

https://baijiahao.baidu.com/s?id=1588360384441579227&wfr=spider&for=pc

https://blog.csdn.net/u012436149/article/details/53837651

https://blog.csdn.net/jerr__y/article/details/57084008

 

Session.run()和Tensor.eval()有什么区别?

最重要的区别是,可以使用sess.run()在相同的步骤中获取多个Tensor(张量)的值, 而eval不能处理对象列表数据

 ut.eval()  # runs one step
 sess.run([tu, ut])  # evaluates both tensors in a single step

 

InteractiveSession 可以想像成 command, 一边敲command一边执行。

Session可以想象成 job, 写好了全部code后扔到服务器自己执行了。

 

 

tf.Variable:主要在于一些可训练变量(trainable variables),比如模型的权重(weights,W)或者偏执值(bias);

  • 声明时,必须提供初始值;
  • 名称的真实含义,在于变量,也即在真实训练时,其值是会改变的,自然事先需要指定初始值

tf.placeholder:用于得到传递进来的真实的训练样本:

  • 不必指定初始值,可在运行时,通过 Session.run 的函数的 feed_dict 参数指定;
  • 这也是其命名的原因所在,仅仅作为一种占位符;
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
output = tf.multiply(input1, input2)

with tf.Session() as sess:
    print sess.run([output], feed_dict={input1:[7.0], input2:[2.0]})

  

 

posted @ 2018-04-16 17:54  YYYYQQQQ  阅读(145)  评论(0编辑  收藏  举报