简体   繁体   English

在Resnet50 keras.applications中修改maxpooling层

[英]Modifying maxpooling layer in Resnet50 keras.applications

I am working on a segmentation project and was wondering if there is a way to modify the resent50 maxpooling layer in keras.application. 我正在研究一个细分项目,想知道是否有一种方法可以修改keras.application中的resent50 maxpooling层。 I'm using keras.application in a Kaggle kernel and was wondering if I could update the layer through code. 我在Kaggle内核中使用keras.application,想知道是否可以通过代码更新该层。

x = ZeroPadding2D(padding=(3, 3), name='conv1_pad')(img_input)
x = Conv2D(64, (7, 7), strides=(2, 2), name='conv1')(img_input)
x = BatchNormalization(axis=bn_axis, name='bn_conv1')(x)
x = Activation('relu')(x)
x = MaxPooling2D((3, 3), strides=(2, 2))(x)

to: 至:

x = Conv2D(64, (7, 7), strides=(2, 2), padding='same', name='conv1')(img_input)
x = BatchNormalization(axis=bn_axis, name='bn_conv1')(x)
x = Activation('relu')(x)
x = MaxPooling2D((3, 3), strides=(2, 2), padding = 'same')(x)

You can always copy the source code and create alternative versions. 您始终可以复制源代码并创建替代版本。

Copy the source code for resnet, rename the class to CustomResnet and change what you want. 复制resnet的源代码,将类重命名为CustomResnet并更改所需的内容。

From my experience with segmentation, though, this will not help you much if you intend to use it with variable sizes, because at the time you perform the UpSamplings, you will not know the original size of the image. 但是,根据我的分割经验,如果打算以可变大小使用它,这将无济于事,因为在执行UpSamplings时,您将不知道图像的原始大小。 So the UpSamplings will often end up bigger than the original. 因此,UpSamplings最终通常会比原始样本更大。

Now, if you're working with fixed sizes, OK, you can end up finding a way of padding properly inside the model. 现在,如果您使用固定大小,可以,您最终可以找到在模型内部正确填充的方法。

But I really suggest you count the amount of MaxPooling layers and make sure your input images sizes are multiples of 2^poolingLayers . 但我确实建议您计算MaxPooling层的数量,并确保输入图像的大小是2^poolingLayers

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

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