当前位置:网站首页>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
边栏推荐
- 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 difference between encodeuri and encodeuricomponent
- 【Hcip】OSPF常用的6种LSA详解
- 解决win7 中powershell挖矿占用CPU100%
- Plug in for vscode
- Windows MySQL 8 zip installation
- Innovation and management based on Scrum
- 【工欲善其事必先利其器】论文编辑及文献管理(Endnote,Latex,JabRef ,overleaf)资源下载及使用指南
- VirtualBox virtual machine (Oracle VM)
- 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.
猜你喜欢
随机推荐
php+mysql對下拉框搜索的內容修改
Navicat premium import SQL file
Fashion MNIST 数据集分类训练
Classification and regression tree of machine learning
Kubernetes - Introduction to actual combat
B blocks of the 46th ICPC Asian regional competition (Kunming)
Rhcsa day 1 operation
Day 3 of learning rhcsa
Looking for a job, writing a resume to an interview, this set of information is enough!
Close the computer port
Publish to NPM?
Chapter V project quality management of information system project manager summary
JZ22 鏈錶中倒數最後k個結點
Rhcsa second day operation
Get together to watch (detailed version) eat a few cents a day
工业互联网+危化安全生产综合管理平台怎样建
Practice of industrial defect detection project (III) -- Based on FPN_ PCB defect detection of tensorflow
Redis data server / database / cache (2022)
ROP Emporium x86_ 64 7 ~ 8 questions
OCR recognition PDF file









