简体   繁体   English

Keras - 关于输入层节点数量的混淆

[英]Keras - Confusion about number of input layer nodes

So, when input_dim=3, it means that the input to a layer is three nodes right?那么,当 input_dim=3 时,表示一个层的输入是三个节点对吧? But what about when input_shape attribute is used and there are more than one values?但是当使用 input_shape 属性并且有多个值时呢? For example:例如:

model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=(82, 82, 3)))

Here, the convolutional layer has 32 output nodes, but how many input nodes does it have?这里,卷积层有32个output节点,但是它有多少个输入节点呢?

model.summary() gives this: model.summary() 给出了这个:

Model: "sequential_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_1 (Conv2D)            (None, 80, 80, 32)        896       
_________________________________________________________________
activation_1 (Activation)    (None, 80, 80, 32)        0         
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 40, 40, 32)        0         
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 38, 38, 32)        9248      
_________________________________________________________________
activation_2 (Activation)    (None, 38, 38, 32)        0         
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 19, 19, 32)        0         
_________________________________________________________________
conv2d_3 (Conv2D)            (None, 17, 17, 64)        18496     
_________________________________________________________________
activation_3 (Activation)    (None, 17, 17, 64)        0         
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 8, 8, 64)          0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 4096)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 64)                262208    
_________________________________________________________________
activation_4 (Activation)    (None, 64)                0         
_________________________________________________________________
dropout_1 (Dropout)          (None, 64)                0         
_________________________________________________________________
dense_2 (Dense)              (None, 1)                 65        
_________________________________________________________________
activation_5 (Activation)    (None, 1)                 0         
=================================================================
Total params: 290,913
Trainable params: 290,913
Non-trainable params: 0
_________________________________________________________________

Here Input_shape is used for images:这里 Input_shape 用于图像:

Your example contain images shape 82x82x3 ==20172 which is equal to input node:您的示例包含形状为 82x82x3 ==20172 的图像,它等于输入节点:

** How would you check this ** **你会如何检查这个**

print(model.summary())

model.summary gives you complete detail of each layer model.summary 为您提供每一层的完整细节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM