LION.models.CNNs.MSDNet

The Mixed-Scale Dense network (Pelt and Sethian, 2018), as msd_pytorch (Hendriksen, 2019) implements it, in plain PyTorch.

msd_pytorch is the reference implementation, but it is no longer maintained and needs compiling (CUDA kernels, PyTorch 1.8, Python up to 3.9). This is the same network, with the same initialisation and padding, and its same memory use: the layers write their outputs into one buffer, and the gradients are computed layer by layer, so memory grows with the depth, not its square (each layer’s input is all the layers before it, and storing them for autograd one by one would grow with the square). On a GPU, each layer is a Triton kernel (_msd_triton, as msd_pytorch’s CUDA kernels; Triton comes with PyTorch, nothing to compile); otherwise plain torch, a group of input channels at a time.

Classes

MSDNet([model_parameters])

Mixed-Scale Dense network (Pelt and Sethian, 2018), as msd_pytorch (Hendriksen, 2019): a deep, narrow network of dilated 3x3 convolutions, each layer seeing the input and all the layers before it, ending in a 1x1 convolution of all of them.


class LION.models.CNNs.MSDNet.MSDNet(model_parameters=None)[source]

Bases: LIONmodel

Mixed-Scale Dense network (Pelt and Sethian, 2018), as msd_pytorch (Hendriksen, 2019): a deep, narrow network of dilated 3x3 convolutions, each layer seeing the input and all the layers before it, ending in a 1x1 convolution of all of them. Takes images (e.g. a reconstruction), or with model_input_type SINOGRAM, the measurements.

Each hidden layer is width convolutions with a bias and a ReLU, of dilation dilations[i % len(dilations)], padded by symmetric reflection; the output layer is linear (a 1x1 convolution with a bias, no activation), for regression. The hidden convolutions start as in the paper (normal, std sqrt(2 / n), n the inputs of a layer at full depth), the biases and the output layer at zero (so the untrained network gives 0).

Memory grows with the depth (the module’s description says how). Backward can’t be differentiated again (e.g. a Jacobian penalty on the network, LION.losses.jacobian_penalty, needs it).

model_parameters (default_parameters()):

  • in_channels, out_channels: of the input and output images (1, 1);

  • width: the channels each layer adds (1);

  • depth: the number of hidden layers (100);

  • dilations: repeated over the layers (1 to 10).

The network for model_parameters (default_parameters() if None).

reset_parameters()[source]

The initial weights (see the class): as msd_pytorch’s.

static default_parameters()[source]

The paper’s network: 100 layers of width 1, dilations 1 to 10 (see the class).

forward(x)[source]

The network’s output for the images x (B, in_channels, H, W).

static cite(cite_format='bib')[source]

Where MSDNet comes from: its citation, BibTeX (“bib”) or “MLA”.