(shape)
| 30 | |
| 31 | |
| 32 | def VGG16_AvgPool(shape): |
| 33 | # we want to account for features across the entire image |
| 34 | # so get rid of the maxpool which throws away information |
| 35 | vgg = VGG16(input_shape=shape, weights='imagenet', include_top=False) |
| 36 | |
| 37 | # new_model = Sequential() |
| 38 | # for layer in vgg.layers: |
| 39 | # if layer.__class__ == MaxPooling2D: |
| 40 | # # replace it with average pooling |
| 41 | # new_model.add(AveragePooling2D()) |
| 42 | # else: |
| 43 | # new_model.add(layer) |
| 44 | |
| 45 | i = vgg.input |
| 46 | x = i |
| 47 | for layer in vgg.layers: |
| 48 | if layer.__class__ == MaxPooling2D: |
| 49 | # replace it with average pooling |
| 50 | x = AveragePooling2D()(x) |
| 51 | else: |
| 52 | x = layer(x) |
| 53 | |
| 54 | return Model(i, x) |
| 55 | |
| 56 | def VGG16_AvgPool_CutOff(shape, num_convs): |
| 57 | # there are 13 convolutions in total |
no test coverage detected