Skip to Content
Deep Learning with PyTorch
book

Deep Learning with PyTorch

by Vishnu Subramanian
February 2018
Intermediate to advanced
262 pages
6h 59m
English
Packt Publishing
Content preview from Deep Learning with PyTorch

DenseBlock

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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Deep Learning with PyTorch

Deep Learning with PyTorch

Eli Stevens, Thomas Viehmann, Luca Pietro Giovanni Antiga
Grokking Deep Learning

Grokking Deep Learning

Andrew W. Trask

Publisher Resources

ISBN: 9781788624336Supplemental Content