Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

How to create ResNetD? #204

Open
KudzayiKing opened this issue Mar 16, 2021 · 0 comments
Open

How to create ResNetD? #204

KudzayiKing opened this issue Mar 16, 2021 · 0 comments

Comments

@KudzayiKing
Copy link

KudzayiKing commented Mar 16, 2021

Hi, i have been trying to create a ResNet50D , mainly by adding an avg_pool() layer before the 1x1 conv2D in the downsampling block ,but I am getting dimension error , How can I fix this problem ? I have attached the code , is the averagepooling2D layer supposed to be shortcut ?

IMG_20210316_123927.jpg

`def convolutional_block(X, f, filters, stage, block, s = 2):

conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_branch'
F1, F2, F3 = filters
X_shortcut = X
X = Conv2D(F1, (1, 1), strides = (s,s), name = conv_name_base + '2a', kernel_initializer = glorot_uniform(seed=0))(X)
X = BatchNormalization(axis = 3, name = bn_name_base + '2a')(X)
X = Activation('relu')(X)

X = Conv2D(filters = F2, kernel_size = (f, f), strides = (1,1), padding = 'same', name = conv_name_base + '2b', kernel_initializer = glorot_uniform(seed=0))(X)
X = BatchNormalization(axis = 3, name = bn_name_base + '2b')(X)
X = Activation('relu')(X)

X = Conv2D(filters = F3, kernel_size = (1, 1), strides = (1,1), padding = 'valid', name = conv_name_base + '2c', kernel_initializer = glorot_uniform(seed=0))(X)
X = BatchNormalization(axis = 3, name = bn_name_base + '2c')(X)

X_shortcut = AveragePooling2D(pool_size=(2, 2),name='avg_pool')(X_shortcut)
X_shortcut = Conv2D(filters = F3, kernel_size = (1, 1), strides = (s,s), padding = 'valid', name = conv_name_base + '1', kernel_initializer = glorot_uniform(seed=0))(X_shortcut)
X_shortcut = BatchNormalization(axis = 3, name = bn_name_base + '1')(X_shortcut)

X = Add()([X_shortcut, X])
X = Activation('relu')(X)

return X`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant