Chinaunix首页 | 论坛 | 博客
  • 博客访问: 397258
  • 博文数量: 162
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1501
  • 用 户 组: 普通用户
  • 注册时间: 2016-10-21 19:45
文章分类
文章存档

2018年(1)

2017年(101)

2016年(60)

分类: 大数据

2017-04-21 15:38:05

1. tf.placeholder
placeholder is simply a variable that we will assign data to at a later date. It allows us to create our operations and build our computation graph, without needing the data. In TensorFlow terminology, we then feed data into the graph through these placeholders.
import tensorflow as tf x = tf.placeholder("float", None) y = x * 2 with tf.Session() as session: result = session.run(y, feed_dict={x: [1, 2, 3]}) print(result)
2. tf.matmul
矩阵相乘

3. tf.Variable

import tensorflow as tf x = tf.constant(35, name='x') y = tf.Variable(x + 5, name='y') print(y)  # y.value 0 model = tf.global_variables_initializer() with tf.Session() as session:     session.run(model)     print(session.run(y))  # 40





阅读(873) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~