当前位置:网站首页>tf. keras. layers. Inputlayer function
tf. keras. layers. Inputlayer function
2022-04-23 02:56:00 【Live up to your youth】
The function prototype
tf.keras.layers.InputLayer(input_shape=None,
batch_size=None,
dtype=None,
input_tensor=None,
sparse=None,
name=None,
ragged=None,
type_spec=None,
**kwargs
)
Function USES
The input layer is generally used as the first layer of the linear model , By specifying parameters input_tensor Wrap existing tensors or specify parameters input_shape Create a new placeholder tensor .
tf.compat.v1.disable_eager_execution()
a = tf.compat.v1.placeholder("float", (None, 32))
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_tensor=a),
tf.keras.layers.Dense(64)
])
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense (Dense) (None, 64) 2112
=================================================================
Total params: 2,112
Trainable params: 2,112
Non-trainable params: 0
_________________________________________________________________
First, a placeholder tensor is created a, Shape is (None, 32). And then by specifying input_tensor=a Package tensor a As input tensor . The final output tensor shape is (None, 64).
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=32),
tf.keras.layers.Dense(64)
])
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense (Dense) (None, 64) 2112
=================================================================
Total params: 2,112
Trainable params: 2,112
Non-trainable params: 0
_________________________________________________________________
Specify parameters input_shape=32, Create a placeholder tensor tensor As input tensor , Shape is (None, 32). Through a Dense layer , The final output tensor shape is also (None, 64).
It is worth noting that , If you also specify input_shape and input_tensor, that input_shape Parameter will fail , That is to create an input layer based on the existing tensor .
You can also specify... On other layers input_shape Parameter to omit the layer .
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, input_shape=(None, 32))
])
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense (Dense) (None, None, 64) 2112
=================================================================
Total params: 2,112
Trainable params: 2,112
Non-trainable params: 0
_________________________________________________________________
By means of Dense Specify on layer input_shape=(None, 32), It's equivalent to creating a tensor with a shape of (None, None, 32) The input layer of . adopt Dense After the layer , The final shape is (None, None, 64).
tf.keras.layers.InputLayer Functions and tf.keras.Input function difference :
tf.keras.Input The function returns a tensor Tensor,tf.keras.layers.InputLayer Function is a layer object . The suggestion on the official website is to use tf.keras.Input Function to create a InputLayer Input layer , Instead of using it directly tf.keras.layers.InputLayer To define the input layer .
版权声明
本文为[Live up to your youth]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220657127417.html
边栏推荐
- eventBus
- Shell script learning notes -- shell operation on files sed
- The space between the left and right of the movie ticket seats is empty and cannot be selected
- Devil cold rice 𞓜 078 devil answers the market in Shanghai and Nanjing; Communication and guidance; Winning the country and killing and screening; The purpose of making money; Change other people's op
- The penultimate K nodes in jz22 linked list
- windows MySQL8 zip安装
- Flink stream processing engine system learning (II)
- Navicat premium import SQL file
- JZ76 删除链表中重复的结点
- [hcip] detailed explanation of six LSAS commonly used by OSPF
猜你喜欢

重大危险源企业如何保障年底前完成双预防机制数字化建设任务

期中汇总(概论+应用层+运输层)

Linux redis - redis database caching service

解决win7 中powershell挖矿占用CPU100%

C language 171 Number of recent palindromes

机器学习(周志华) 第十四章概率图模型

JS learning notes

Linux Redis ——Redis HA Sentinel 集群搭建详解 & Redis主从部署

ele之Table表格的封装

Domestic lightweight Kanban scrum agile project management tool
随机推荐
Navicat failed to connect to Oracle Database: cannot load OCI DLL, 87: instant client package is
The way to conquer C language
[hcip] detailed explanation of six LSAS commonly used by OSPF
AC380V drop 5v12v24v200ma, UHV non isolated chip IC scheme
Classification and regression tree of machine learning
win查看端口占用 命令行
Traversée de l'arbre L2 - 006
Encapsulate components such as pull-down menu based on ele
基于Scrum进行创新和管理
The shell monitors the depth of the IBM MQ queue and scans it three times in 10s. When the depth value exceeds 5 for more than two times, the queue name and depth value are output.
JZ35 replication of complex linked list
Modification du contenu de la recherche dans la boîte déroulante par PHP + MySQL
Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl
The express project changes the jade template to art template
[learn junit5 from official documents] [II] [writingtests] [learning notes]
第46届ICPC亚洲区域赛(昆明) B Blocks(容斥+子集和DP+期望DP)
Flink stream processing engine system learning (III)
Intelligent agricultural management model
Regular object type conversion tool - Common DOM class
基于多态的职工管理系统源码与一些理解