inceptionblock
InceptionBlock
¶
Bases: Module
Inception block as used in GoogLeNet.
Notes
Description from P. Lippe:INCEPTION, RESNET AND DENSENET An Inception block applies four convolution blocks separately on the same feature map: a 1x1, 3x3, and 5x5 convolution, and a max pool operation. This allows the network to look at the same data with different receptive fields. Of course, learning only 5x5 convolution would be theoretically more powerful. However, this is not only more computation and memory heavy but also tends to overfit much easier. The 1x1 convolutions are used to reduce the number of input channels to the 3x3 and 5x5 convolutions, which reduces the number of parameters and computation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_in |
int
|
Number of input feature maps from the previous layers |
required |
c_red |
dict
|
Dictionary with keys “3x3” and “5x5” specifying the output of the dimensionality reducing 1x1 convolutions |
required |
c_out |
dict
|
Dictionary with keys “1x1”, “3x3”, “5x5”, and “max” |
required |
act_fn |
Module
|
Activation class constructor (e.g. nn.ReLU) |
required |
Examples:
>>> from spotpython.light.cnn.googlenet import InceptionBlock
import torch
import torch.nn as nn
block = InceptionBlock(3,
{"3x3": 32, "5x5": 16},
{"1x1": 16, "3x3": 32, "5x5": 8, "max": 8},
nn.ReLU)
x = torch.randn(1, 3, 32, 32)
y = block(x)
y.shape
torch.Size([1, 64, 32, 32])
Source code in spotpython/light/cnn/inceptionblock.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|