February 2018
Intermediate to advanced
262 pages
6h 59m
English
Let's look at the code for DenseBlock and then walk through it:
class _DenseBlock(nn.Sequential): def __init__(self, num_layers, num_input_features, bn_size, growth_rate, drop_rate): super(_DenseBlock, self).__init__() for i in range(num_layers): layer = _DenseLayer(num_input_features + i * growth_rate, growth_rate, bn_size, drop_rate) self.add_module('denselayer%d' % (i + 1), layer)
DenseBlock is a sequential module where we add layers in a sequential order. Based on the number of layers (num_layers) in the block, we add that number of _Denselayer objects along with a name to it. All the magic is happening inside the DenseLayer. Let's look at what goes on inside the DenseLayer.