tensorflow 学习

tensorflow: tensor 沿着graph 传递闭包完成flow的过程。

简单运算:

import tensorflow as tf

# Build a graph.
a = tf.constant([1.0, 2.0])
b = tf.constant([3.0, 4.0])
c = a * b

# Launch the graph in a session.
sess = tf.Session()

# Evaluate the tensor 'c'.
print sess.run(c)
sess.close()

  session 中有资源如variable等。不需要时就要释放。 使用session.close(), with tf.Session() 创建上下文来执行自动释放。

Session 类的构造函数: tf.Session.__init__(target='',graph=None,config=None)

线性回归:

原文地址:https://www.cnblogs.com/fanhaha/p/7604180.html