当前位置:网站首页>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
边栏推荐
- Liunx foundation - zabbix5 0 monitoring system installation and deployment
- [wechat applet] set the bottom menu (tabbar) for the applet
- OCR recognition PDF file
- Traversal of l2-006 tree (middle and later order determination binary tree & sequence traversal)
- MySQL / SQL Server判断表或临时表存在则删除
- win查看端口占用 命令行
- JSON data text
- 【Hcip】OSPF常用的6种LSA详解
- Kubernetes study notes
- The usage of case when and select case when is very easy to use
猜你喜欢

Looking for a job, writing a resume to an interview, this set of information is enough!

LeetCode 1450 - 1453

How can enterprises with major hazard installations ensure the completion of the digital construction task of double prevention mechanism by the end of the year

The way to conquer C language

Actual combat of industrial defect detection project (IV) -- ceramic defect detection based on hrnet

Encapsulate components such as pull-down menu based on ele

grain rain

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

Machine learning (Zhou Zhihua) Chapter 14 probability graph model

Fashion MNIST dataset classification training
随机推荐
Kubernetes - Introduction to actual combat
Chapter V project quality management of information system project manager summary
Mosaic Routing: implement / home / news
国产轻量级看板式Scrum敏捷项目管理工具
First day of rhcsa
C语言 171. 最近回文数
OCR recognition PDF file
Résumé du gestionnaire de projet du système d'information Chapitre VI gestion des ressources humaines du projet
Liunx foundation - zabbix5 0 monitoring system installation and deployment
Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl
《信息系统项目管理师总结》第七章 项目沟通管理
Decision tree principle of machine learning
Win view port occupation command line
Those years can not do math problems, using pyhon only takes 1 minute?
Slave should be able to synchronize with the master in tests/integration/replication-psync. tcl
Modify the content of MySQL + PHP drop-down box
Step principle of logical regression in machine learning
php+mysql对下拉框搜索的内容修改
Fashion MNIST dataset classification training
《信息系统项目管理师总结》第四章 项目成本管理