keras.Sequential.summary()函数是否很好地计算了参数?

时间:2019-06-12 02:48:03

标签: tensorflow summary

我正在使用summary()函数来获取网络配置文件并获取总参数,我遇到了我认为是错误的地方。

我没有使用任何打印功能,而我调用该功能的方式就像:“ model.summary(line_length = 36,position = [15,43,40])”

网络A:

    ____________________________________
    Layer (type)   Output Shape             
    ====================================
    conv2d_170 (Co (None, 28, 28, 128)      
    ____________________________________
    max_pooling2d_ (None, 14, 14, 128)      
    ____________________________________
    flatten_68 (Fl (None, 25088)            
    ____________________________________
    dense_132 (Den (None, 128)              
    ____________________________________
    dense_133 (Den (None, 128)              
    ____________________________________
    dropout_68 (Dr (None, 128)              
    ____________________________________
    dense_134 (Den (None, 10)               
    ====================================
    Total params: 3,232,522
    Trainable params: 3,232,522
    Non-trainable params: 0

网络B:

    ____________________________________
    Layer (type)   Output Shape             
    ====================================
    conv2d_176 (Co (None, 28, 28, 128)      
    ____________________________________
    max_pooling2d_ (None, 14, 14, 128)      
    ____________________________________
    conv2d_177 (Co (None, 13, 13, 128)      
    ____________________________________
    max_pooling2d_ (None, 7, 7, 128)        
    ____________________________________
    conv2d_178 (Co (None, 6, 6, 128)        
    ____________________________________
    max_pooling2d_ (None, 3, 3, 128)        
    ____________________________________
    conv2d_179 (Co (None, 2, 2, 128)        
    ____________________________________
    max_pooling2d_ (None, 1, 1, 128)        
    ____________________________________
    flatten_71 (Fl (None, 128)              
    ____________________________________
    dense_141 (Den (None, 128)              
    ____________________________________
    dense_142 (Den (None, 128)              
    ____________________________________
    dropout_71 (Dr (None, 128)              
    ____________________________________
    dense_143 (Den (None, 10)               
    ====================================
    Total params: 234,634
    Trainable params: 234,634
    Non-trainable params: 0

可以预期,网络B将具有更多可训练的参数,而这不会发生。

0 个答案:

没有答案