neupy.architectures.resnet50

neupy.architectures.resnet50(input_shape=(224, 224, 3), include_global_pool=True, in_out_ratio=32)[source]

ResNet50 network architecture with random parameters. Parameters can be loaded using neupy.storage module.

ResNet50 has roughly 25.5 million parameters.

Parameters:
input_shape : tuple

Network’s input shape. Defaults to (224, 224, 3).

include_global_pool : bool

Specifies if returned output should include global pooling layer. Defaults to True.

in_out_ratio : {4, 8, 16, 32}

Every layer that applies strides reduces height and width per every image. There are 5 of these layers in Resnet and at the end each dimensions gets reduced by 32. For example, 224x224 image will be reduced to 7x7 image patches. This parameter specifies what level of reduction we want to obtain after we’ve propagated network through all the convolution layers.

See also

vgg16
VGG16 network
squeezenet
SqueezeNet network
resnet50
ResNet-50 network

Notes

Because of the global pooling layer, ResNet50 can be applied to the images with variable sizes. The only limitation is that image size should be bigger than 32x32, otherwise network won’t be able to apply all transformations to the image.

References

Deep Residual Learning for Image Recognition. https://arxiv.org/abs/1512.03385

Examples

ResNet-50 for ImageNet classification

>>> from neupy import architectures, algorithms
>>>
>>> resnet = architectures.resnet50()
>>> resnet
(?, 224, 224, 3) -> [... 187 layers ...] -> (?, 1000)
>>>
>>> optimizer = algorithms.Momentum(resnet50)

ResNet-50 for custom classification task

>>> from neupy import architectures
>>> resnet = architectures.resnet50(include_global_pool=False)
>>> resnet
(?, 224, 224, 3) -> [... 185 layers ...] -> (?, 7, 7, 2048)
>>>
>>> from neupy.layers import *
>>> resnet = resnet >> GlobalPooling('avg') >> Softmax(21)
(?, 224, 224, 3) -> [... 187 layers ...] -> (?, 21)

ResNet-50 for image segmentation

>>> from neupy import architectures
>>> resnet = architectures.resnet50(
...     include_global_pool=False,
...     in_out_ratio=8,
... )
>>> resnet
(?, 224, 224, 3) -> [... 185 layers ...] -> (?, 28, 28, 2048)