layers01
-
class
packnet_sfm.networks.layers.packnet.layers01.
Conv2D
(in_channels, out_channels, kernel_size, stride)[source] Bases:
torch.nn.modules.module.Module
2D convolution with GroupNorm and ELU
- Parameters
in_channels (int) – Number of input channels
out_channels (int) – Number of output channels
kernel_size (int) – Kernel size
stride (int) – Stride
-
forward
(x)[source] Runs the Conv2D layer.
-
class
packnet_sfm.networks.layers.packnet.layers01.
InvDepth
(in_channels, out_channels=1, min_depth=0.5)[source] Bases:
torch.nn.modules.module.Module
Inverse depth layer
-
forward
(x)[source] Runs the InvDepth layer.
-
-
class
packnet_sfm.networks.layers.packnet.layers01.
PackLayerConv2d
(in_channels, kernel_size, r=2)[source] Bases:
torch.nn.modules.module.Module
Packing layer with 2d convolutions. Takes a [B,C,H,W] tensor, packs it into [B,(r^2)C,H/r,W/r] and then convolves it to produce [B,C,H/r,W/r].
-
forward
(x)[source] Runs the PackLayerConv2d layer.
-
-
class
packnet_sfm.networks.layers.packnet.layers01.
PackLayerConv3d
(in_channels, kernel_size, r=2, d=8)[source] Bases:
torch.nn.modules.module.Module
Packing layer with 3d convolutions. Takes a [B,C,H,W] tensor, packs it into [B,(r^2)C,H/r,W/r] and then convolves it to produce [B,C,H/r,W/r].
-
forward
(x)[source] Runs the PackLayerConv3d layer.
-
-
packnet_sfm.networks.layers.packnet.layers01.
ResidualBlock
(in_channels, out_channels, num_blocks, stride, dropout=None)[source] Returns a ResidualBlock with various ResidualConv layers.
- Parameters
in_channels (int) – Number of input channels
out_channels (int) – Number of output channels
num_blocks (int) – Number of residual blocks
stride (int) – Stride
dropout (float) – Dropout value
-
class
packnet_sfm.networks.layers.packnet.layers01.
ResidualConv
(in_channels, out_channels, stride, dropout=None)[source] Bases:
torch.nn.modules.module.Module
2D Convolutional residual block with GroupNorm and ELU
-
forward
(x)[source] Runs the ResidualConv layer.
-
-
class
packnet_sfm.networks.layers.packnet.layers01.
UnpackLayerConv2d
(in_channels, out_channels, kernel_size, r=2)[source] Bases:
torch.nn.modules.module.Module
Unpacking layer with 2d convolutions. Takes a [B,C,H,W] tensor, convolves it to produce [B,(r^2)C,H,W] and then unpacks it to produce [B,C,rH,rW].
-
forward
(x)[source] Runs the UnpackLayerConv2d layer.
-
-
class
packnet_sfm.networks.layers.packnet.layers01.
UnpackLayerConv3d
(in_channels, out_channels, kernel_size, r=2, d=8)[source] Bases:
torch.nn.modules.module.Module
Unpacking layer with 3d convolutions. Takes a [B,C,H,W] tensor, convolves it to produce [B,(r^2)C,H,W] and then unpacks it to produce [B,C,rH,rW].
-
forward
(x)[source] Runs the UnpackLayerConv3d layer.
-
-
packnet_sfm.networks.layers.packnet.layers01.
packing
(x, r=2)[source] Takes a [B,C,H,W] tensor and returns a [B,(r^2)C,H/r,W/r] tensor, by concatenating neighbor spatial pixels as extra channels. It is the inverse of nn.PixelShuffle (if you apply both sequentially you should get the same tensor)
- Parameters
x (torch.Tensor [B,C,H,W]) – Input tensor
r (int) – Packing ratio
- Returns
out – Packed tensor
- Return type
torch.Tensor [B,(r^2)C,H/r,W/r]