当前位置:网站首页>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}))
边栏推荐
- 人人都可以DIY的大玩具,宏光MINIEV GAMEBOY产品力强,出行新装备
- DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine reduce the immunogenicity of peptides
- hdu 3341 Lost's revenge(dp+Ac自动机)
- Problems with compiling SIP with QGIS
- json事例
- kvm虚拟机出现启动不了,NOT available,PV大于分区
- Tensorflow中使用convert_to_tensor去指定数据的类型
- 简单问题窥见数学
- 定投的基金
- TF生成均匀分布的tensor
猜你喜欢
DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine reduce the immunogenicity of peptides
Don't tell me to play, I'm taking the PMP exam: what you need to know about choosing an institution for the PMP exam
Word怎么设置图片衬于文字下方?两种方法教你设置Word图片衬于文字下方
MySQL慢查询的多个原因
人人都可以DIY的大玩具,宏光MINIEV GAMEBOY产品力强,出行新装备
LoRa Basics无线通信技术和应用案例详解
[corctf 2022] section
【泛型编程】模板全详解
【双链表增删查改接口的实现】
必看设计干货|易知微设计师是怎么做标准可视化设计服务的?
随机推荐
Problems with compiling SIP with QGIS
DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine reduce the immunogenicity of peptides
【双链表增删查改接口的实现】
人人都可以DIY的大玩具,宏光MINIEV GAMEBOY产品力强,出行新装备
Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
linux定时执行sql文件[通俗易懂]
Optimization of SQL Statements and Indexes
gmail+mtalk配合打免费网络电话。
leetcode:数组中的第K个最大元素
How to fix Windows 11 not finding files
APP自动化测试框架-UiAutomator2基础入门
定投的基金
LoRa Basics无线通信技术和应用案例详解
[corctf 2022] 部分
Pagoda measurement - building LightPicture open source map bed system
Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)
上海控安SmartRocket系列产品推介(三):SmartRocket iVerifier计算机联锁系统验证工具
AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
Daily practice of PMP | Do not get lost in the exam -8.8 (including agility + multiple choice)
威纶通触摸屏制作自定义弹出窗口的具体方法(3种)