简体   繁体   中英

How many model parameters do we need to optimize for the following CNN model?

We use the following convolutional neural network to classify a set of 32×32 greyscale images (so the input size will be 32$\\times$32$\\times$1):

  1. Layer 1: convolutional layer with the ReLU nonlinear activation function, 100 5×5 filters with stride 1.

  2. Layer 2: 2×2 max-pooling layer

  3. Layer 3: convolutional layer with the ReLU nonlinear activation function, 50 3×3 filters with stride 1.

  4. Layer 4: 2×2 max-pooling layer

  5. Layer 5: fully-connected layer

  6. Layer 6: classification layer

How many model parameters do we need to optimize in the first layer and in the second layer (assume the bias term is used)

You can use tensorflow to display the number of trainable parameters:

import tensorflow as tf
from tensorflow.keras import layers

def make_model():
    model = tf.keras.Sequential()
    model.add(layers.Conv2D(100, (5, 5), strides=1,input_shape=[32, 32, 1]))
    model.add(layers.LeakyReLU())
    model.add(layers.MaxPooling2D(pool_size=(2, 2)))

    return model

model=make_model()

model.summary()

This gives 2600 trainable params and 0 non-trainable params.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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