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
|
Mixed-Scale Dense network (Pelt and Sethian, 2018), as |
- class LION.models.CNNs.MSDNet.MSDNet(model_parameters=None)[source]¶
Bases:
LIONmodelMixed-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 withmodel_input_typeSINOGRAM, the measurements.Each hidden layer is
widthconvolutions with a bias and a ReLU, of dilationdilations[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).