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 ...
随机推荐
- 用栈来递归 模板 honoi
用栈来模拟递归的技巧 #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<vector> #include& ...
- DS作业·写了一个链表
用struct手写了个list 有push_back,push_front,insert,erase reserve,size,setpos,rbegin 功能. 坑:一开始想用template< ...
- iOS-程序启动原理和UIApplication(转载)
一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就代表一个应用程序. (2)每一个应用都有自己的UIApplica ...
- libevent 网络IO分析
libevent 网络IO分析 Table of Contents 1. 简介 2. 简单使用与入门 2.1. 定时器-timeout 超时回调 2.2. 信号事件 2.3. 读取 socket 3. ...
- 2018最新php笔试题及答案(持续更新)
php中include和require的区别 在 PHP 中,您可以在服务器执行 PHP 文件之前在该文件中插入一个文件的内容.include 和 require 语句用于在执行流中插入写在其他文件中 ...
- WordPress已占全球网站平台18.9%的份额
Automattic创始人马特·穆伦维格(Matt Mullenweg)在旧金山的WordCamp会议上谈到了旗下博客平台WordPress的最新发展情况.WordPress平台已成为全球18.9%网 ...
- Android开发之改动屏幕方向
有的场景下.我们须要把手机屏幕方向改变,以下是我写的一个样例. xml页面文件: <RelativeLayout xmlns:android="http://schemas.andro ...
- Dokcerfile部署webpy,安装imagehash库并运行py脚本获取图片dhash值
Dockerfile FROM lmurawsk/python2.7 RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple image ...
- openstack 部署笔记--dashboard
控制节点 # yum install openstack-dashboard # vim /etc/openstack-dashboard/local_settings OPENSTACK_HOST ...
- mysql 开启慢查询
linux启用MySQL慢查询 vim /etc/my.cnf [mysqld] slow-query-log = on slow_query_log_file = /var/log/slow_que ...