当前位置:网站首页>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
边栏推荐
- Essential qualities of advanced programmers
- Fashion MNIST dataset classification training
- Encapsulate components such as pull-down menu based on ele
- Win view port occupation command line
- Leangoo brain map - shared multi person collaborative mind mapping tool
- leangoo脑图-共享式多人协作思维导图工具分享
- Navicat failed to connect to Oracle Database: cannot load OCI DLL, 87: instant client package is
- 解决win7 中powershell挖矿占用CPU100%
- win查看端口占用 命令行
- 学习正则表达式选项、断言
猜你喜欢
Rhcsa day 1 operation
Looking for a job, writing a resume to an interview, this set of information is enough!
Linux Redis——Redis 数据库缓存服务
Intelligent agricultural management model
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
Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl
Liunx foundation - zabbix5 0 monitoring system installation and deployment
Domestic lightweight Kanban scrum agile project management tool
[unity3d] rolling barrage effect in live broadcasting room
leangoo脑图-共享式多人协作思维导图工具分享
随机推荐
Machine learning (Zhou Zhihua) Chapter 14 probability graph model
Mosaic Routing: implement / home / news
Looking for a job, writing a resume to an interview, this set of information is enough!
AC380V drop 5v12v24v200ma, UHV non isolated chip IC scheme
Linux redis - redis database caching service
Essential qualities of advanced programmers
Regular object type conversion tool - Common DOM class
Get together to watch (detailed version) eat a few cents a day
JZ22 链表中倒数最后k个结点
[hcip] detailed explanation of six LSAS commonly used by OSPF
Android high-level interview must ask: overall business and project architecture design and reconstruction
Codeforces Round #784 (Div. 4) (A - H)题解
Traversal of l2-006 tree (middle and later order determination binary tree & sequence traversal)
Log cutting - build a remote log collection server
The space between the left and right of the movie ticket seats is empty and cannot be selected
JZ76 删除链表中重复的结点
Windows MySQL 8 zip installation
MySQL function syntax
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
Flink stream processing engine system learning (II)