tf.placeholder使用说明
tf.placeholder(dtype, shape=None, name=None)
placeholder,占位符,在tensorflow中类似于函数参数,运行时必须传入值。
- dtype:数据类型。常用的是tf.float32,tf.float64等数值类型。
- shape:数据形状。默认是None,就是一维值,也可以是多维,比如[2,3], [None, 3]表示列是3,行不定。
- name:名称。
代码片段-1(计算3*4=12)
- #!/usr/bin/env python
- # _*_ coding: utf-8 _*_
- import tensorflow as tf
- import numpy as np
- 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:[3.], input2: [4.]})
代码片段-2(计算矩阵相乘,x*x)
- #!/usr/bin/env python
- # _*_ coding: utf-8 _*_
- import tensorflow as tf
- import numpy as np
- x = tf.placeholder(tf.float32, shape=(1024, 1024))
- y = tf.matmul(x, x)
- with tf.Session() as sess:
- # print(sess.run(y)) # ERROR: x is none now
- rand_array = np.random.rand(1024, 1024)
- print(sess.run(y, feed_dict={x: rand_array})) # Will succeed.
tf.placeholder使用说明的更多相关文章
- TensorFlow 辨异 —— tf.placeholder 与 tf.Variable
https://blog.csdn.net/lanchunhui/article/details/61712830 https://www.cnblogs.com/silence-tommy/p/70 ...
- 深度学习原理与框架-Tensorflow基本操作-变量常用操作 1.tf.random_normal(生成正态分布随机数) 2.tf.random_shuffle(进行洗牌操作) 3. tf.assign(赋值操作) 4.tf.convert_to_tensor(转换为tensor类型) 5.tf.add(相加操作) tf.divide(相乘操作) 6.tf.placeholder(输入数据占位
1. 使用tf.random_normal([2, 3], mean=-1, stddev=4) 创建一个正态分布的随机数 参数说明:[2, 3]表示随机数的维度,mean表示平均值,stddev表示 ...
- tf.placeholder
tf.placeholder placeholder( dtype, shape=None, name=None ) 功能说明: 是一种占位符,在执行时候需要为其提供数据 参数列表: 参数名 必选 类 ...
- TensorFlow函数(一)tf.placeholder()函数
tf.placeholder(dtype, shape=None, name=None) 此函数用于定义过程,在执行的时候再赋具体的值 参数: dtype:数据类型.常用的是tf.float32,tf ...
- Tensorflow函数——tf.placeholder()函数
tf.placeholder()函数 Tensorflow中的palceholder,中文翻译为占位符,什么意思呢? 在Tensoflow2.0以前,还是静态图的设计思想,整个设计理念是计算流图,在编 ...
- tf.placeholder类似函数中的形参
tf.placeholder(dtype, shape=None, name=None) 此函数可以理解为形参,用于定义过程,在执行的时候再赋具体的值 参数: dtype:数据类型.常用的是tf.fl ...
- tf.Variable()、tf.get_variable()和tf.placeholder()
1.tf.Variable() tf.Variable(initializer,name) 功能:tf.Variable()创建变量时,name属性值允许重复,检查到相同名字的变量时,由自动别名机制创 ...
- tf.placeholder函数说明
函数形式: tf.placeholder( dtype, shape=None, name=None ) 参数: dtype:数据类型.常用的是tf.float32,tf.fl ...
- tensorflow学习之tf.placeholder
placeholder函数相当于一个占位符,tf.placeholder(dtype, shape=None, name=None) dtype:数据类型.常用的是tf.float32,tf.floa ...
随机推荐
- CSS垂直导航栏
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- nginx map使用方法
map指令使用ngx_http_map_module模块提供的.默认情况下,nginx有加载这个模块,除非人为的 --without-http_map_module.ngx_http_map_modu ...
- 网站搜索引擎优化(SEO)的18条守则
1.永远不要放过网页的title,这个地方应该是你每次优化的重点. 2.请不要在title,deion,keyword里写太多东西,越是贪婪,得到的就越少. 3.网页的头部和底部是很重要的,对于搜索引 ...
- Parity game---poj1733
Description Now and then you play the following game with your friend. Your friend writes down a seq ...
- sublime eslint 和 jshint的安装与使用
jshint简介 jslint是一javascript的语法检测,众多前端自动化工具都又用到,编辑器也用到jshint. webstorm很强大,自身带有,但是我使用的电脑带不动.sublime或者a ...
- 【Python】详解Python多线程Selenium跨浏览器测试
前言 在web测试中,不可避免的一个测试就是浏览器兼容性测试,在没有自动化测试前,我们总是苦逼的在一台或多台机器上安装N种浏览器,然后手工在不同的浏览器上验证主业务流程和关键功能模块功能,以检测不同浏 ...
- 淡入淡出(折叠效果)and点击切换背景图片
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- android奔溃日期一闪而过
Android Studio日期崩溃了一闪而过,看不到原因:可以设置No Filters就可以了
- C#集合中的Add与AddRange方法
C#.NET的集合主要位于System.Collections和System.Collections.Generic(泛型)这两个namespace中. 1.System.Collections 比如 ...
- Java接口多线程并发测试 (二)
原文地址http://www.cnblogs.com/yezhenhan/archive/2012/01/09/2317636.html 这是一篇很不错的文章,感谢原博主的分享! JAVA多线程实现和 ...