From b53d8d9de345d25a1d193d3a757fe21c620f60dd Mon Sep 17 00:00:00 2001 From: Andreas Dominik Date: Fri, 27 Oct 2023 13:17:07 +0200 Subject: [PATCH] resnet imported w/o Pad layer --- src/pretrained.jl | 72 +++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/pretrained.jl b/src/pretrained.jl index 657c0bb4..b47a911b 100644 --- a/src/pretrained.jl +++ b/src/pretrained.jl @@ -211,18 +211,18 @@ function get_resnet50v2(; filters_only=false, trainable=true) h5 = HDF5.h5open(local_file) filter_layers = Chain( - Pad(3), - Conv(h5, "conv1_conv", trainable=trainable, stride=2, actf=identity), - Pad(1), - Pool(;window=3, stride=2), + #Pad(3), + Conv(h5, "conv1_conv", trainable=trainable, stride=2, actf=identity, padding=3), + #Pad(1), + Pool(;window=3, stride=2, padding=1), BatchNorm(h5, "conv2_block1_preact_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), ResNetBlock([ Conv(h5, "conv2_block1_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm( h5, "conv2_block1_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv2_block1_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv2_block1_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv2_block1_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv2_block1_3_conv", trainable=trainable, actf=identity), @@ -236,8 +236,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv2_block2_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm( h5, "conv2_block2_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv2_block2_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv2_block2_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv2_block2_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv2_block2_3_conv", trainable=trainable, actf=identity), @@ -248,8 +248,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv2_block3_1_conv",use_bias=false, trainable=trainable, actf=identity), BatchNorm( h5, "conv2_block3_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv2_block3_2_conv", use_bias=false, stride=2, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv2_block3_2_conv", use_bias=false, stride=2, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv2_block3_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv2_block3_3_conv", trainable=trainable, actf=identity), @@ -265,8 +265,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv3_block1_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv3_block1_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv3_block1_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv3_block1_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv3_block1_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv3_block1_3_conv", trainable=trainable, actf=identity), @@ -280,8 +280,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv3_block2_1_conv"; use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv3_block2_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv3_block2_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv3_block2_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv3_block2_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv3_block2_3_conv", trainable=trainable, actf=identity), @@ -292,8 +292,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv3_block3_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv3_block3_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv3_block3_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv3_block3_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv3_block3_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv3_block3_3_conv", trainable=trainable, actf=identity), @@ -304,8 +304,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv3_block4_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm( h5, "conv3_block4_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv3_block4_2_conv", use_bias=false, trainable=trainable, stride=2, actf=identity), + #Pad(1), + Conv(h5, "conv3_block4_2_conv", use_bias=false, trainable=trainable, stride=2, actf=identity, padding=1), BatchNorm( h5, "conv3_block4_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv3_block4_3_conv", trainable=trainable, actf=identity), @@ -321,8 +321,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv4_block1_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm( h5, "conv4_block1_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv4_block1_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv4_block1_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv4_block1_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv4_block1_3_conv", trainable=trainable, actf=identity), @@ -336,8 +336,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv4_block2_1_conv", use_bias=false, trainable=trainable, padding=0, stride=1, actf=identity), BatchNorm(h5, "conv4_block2_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv4_block2_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv4_block2_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv4_block2_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv4_block2_3_conv", trainable=trainable, padding=0, stride=1, actf=identity), @@ -348,8 +348,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv4_block3_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv4_block3_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv4_block3_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv4_block3_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv4_block3_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv4_block3_3_conv", trainable=trainable, actf=identity), @@ -360,8 +360,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv4_block4_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv4_block4_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv4_block4_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv4_block4_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv4_block4_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv4_block4_3_conv", trainable=trainable, padding=0, stride=1, actf=identity), @@ -372,8 +372,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv4_block5_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv4_block5_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv4_block5_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv4_block5_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv4_block5_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv4_block5_3_conv", trainable=trainable, padding=0, stride=1, actf=identity), @@ -384,8 +384,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv4_block6_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm( h5, "conv4_block6_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv4_block6_2_conv", use_bias=false, trainable=trainable, stride=2, actf=identity), + #Pad(1), + Conv(h5, "conv4_block6_2_conv", use_bias=false, trainable=trainable, stride=2, actf=identity, padding=1), BatchNorm( h5, "conv4_block6_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv4_block6_3_conv", trainable=trainable, padding=0, stride=1, actf=identity), @@ -401,8 +401,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv5_block1_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm( h5, "conv5_block1_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv5_block1_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv5_block1_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv5_block1_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv5_block1_3_conv", trainable=trainable, actf=identity), @@ -416,8 +416,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv5_block2_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv5_block2_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv5_block2_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv5_block2_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv5_block2_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv5_block2_3_conv", trainable=trainable, actf=identity), @@ -428,8 +428,8 @@ function get_resnet50v2(; filters_only=false, trainable=true) Conv(h5, "conv5_block3_1_conv", use_bias=false, trainable=trainable, actf=identity), BatchNorm(h5, "conv5_block3_1_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), - Pad(1), - Conv(h5, "conv5_block3_2_conv", use_bias=false, trainable=trainable, actf=identity), + #Pad(1), + Conv(h5, "conv5_block3_2_conv", use_bias=false, trainable=trainable, actf=identity, padding=1), BatchNorm( h5, "conv5_block3_2_bn", trainable=trainable, momentum=0.99, ε=1.001e-5), Relu(), Conv(h5, "conv5_block3_3_conv", trainable=trainable, actf=identity),