当前位置:网站首页>Usage of placeholder function in Tensorflow
Usage of placeholder function in Tensorflow
2022-08-09 23:12:00 【phac123】
Article table of contents
Introduction
At the code level, each tensor value is an op on the graph. When we divide the train data into minibatches and transfer them to the network for training, each minibatch will be an op. In this case,There are too many ops on a picture, and it will also generate huge overhead; so there is tf.placeholder(), that is, We can pass a minitatch to x = tf.placeholder(tf.float32, [None, 32]), the next incoming x will replace the last incoming x, so that only one op will be generated for all incoming minibatch x, and no otherThe redundant op reduces the overhead of the graph.
The form of the function:
tf.placeholder(dtype,shape = None,name = None)Function parameters:
- dtype: data type; commonly used numerical types such as tf.float32, tf.float64
- shape: data shape; the default is None, which is a one-dimensional value, or it can be multi-dimensional (for example, [2,3], [None, 3] means the column is 3, and the row is indeterminate)
- name: name
Go back
- Tensor type
implemented
import tensorflow as tfimport tensorflow._api.v2.compat.v1 as tftf.disable_v2_behavior()import numpy as npfrom enum import Enumfrom data.create_data import Distributionfrom functools import wrapsx = tf.placeholder(tf.float32)y = tf.constant(5.6)output = tf.add(x, y)with tf.Session() as sess:print(sess.run(output, feed_dict={x:3, y:5}))
边栏推荐
- How to fix Windows 11 not finding files
- 【stack】【queue】【priority_queue】【deque】详解
- 论文解读(DropEdge)《DropEdge: Towards Deep Graph Convolutional Networks on Node Classification》
- [Generic Programming] Full Detailed Explanation of Templates
- 字符串哈希(2014 SERC J题)
- 《强化学习周刊》第57期:DL-DRL、FedDRL & Deep VULMAN
- 基于Docker构建MySQL主从复制数据库
- Leetcode 93 IP addresses
- 凸集与凸函数
- 普源精电上半年扭亏为盈,高端产品持续发力!你看好仪器界“华为”吗?
猜你喜欢

Cholesterol-PEG-Thiol, CLS-PEG-SH, Cholesterol-PEG-Sulfhydryl for improved solubility

【云原生】4.2 DevOps 精讲篇
![[Generic Programming] Full Detailed Explanation of Templates](/img/9d/7864f999cb2e4edda2ee7723558135.png)
[Generic Programming] Full Detailed Explanation of Templates

kvm虚拟机出现启动不了,NOT available,PV大于分区

ACM MM 2022 | Cloud2Sketch: Painting with clouds in the sky, AI brush strokes

Unity2D_线框材质

同步锁synchronized追本溯源

URL Protocol web page to open the application

TF生成均匀分布的tensor
![[Graphic and textual] How to reinstall Win7 system](/img/24/3acccb93e5e219f39477dc77229a58.png)
[Graphic and textual] How to reinstall Win7 system
随机推荐
FS4066耐高压1到4节内置MOS的锂电池充电管理芯片
Referenced file contains errors 完美解决方法
简单问题窥见数学
fixed investment fund
Jmeter 使用正则表达式提取器将返回值全部保存到一个文件中
cad图纸怎么复制到word文档里面?Word里插CAD图怎么弄?
linux定时执行sql文件[通俗易懂]
Several ways to draw timeline diagrams
LoRa无线技术在物联网应用市场的概况和发展
mysql配置参数详解[通俗易懂]
DSPE-PEG-Azide, DSPE-PEG-N3, phospholipid-polyethylene glycol-azide can react directly with DBCO
gmail+mtalk配合打免费网络电话。
APP automation test framework - UiAutomator2 introductory
编程语言中,取余和取模的区别
Word箭头上面怎么打字
6个规则去净化你的代码
Definition and Basic Operations of Sequence Tables
poj 3070 Fibonacci(简单矩阵连乘)
4D Summary: 38 Knowledge Points of Distributed Systems
[corctf 2022] section