struct ResidualBlock {
struct Conv2D conv1;
struct Conv2D conv2;
struct Conv2D projection;
int hasProjection;
}ResNet basic block (He et al. 2016): out = relu(conv2(relu(conv1(x))) + shortcut(x)), conv1 3x3 with 'stride', conv2 3x3 stride 1, both padding 1. The shortcut is x itself, or a 1x1 convolution with 'stride' when the stride is not 1 or the channel count changes (the "projection" shortcut). Output side (dim - 1)/stride + 1. No batch norm: fold a trained model's batch norms into the convolutions' weights and biases.
Fields
used only when hasProjection
Methods
= drop()
§
static struct ResidualBlock new(
unsigned long inChannels,
unsigned long outChannels,
unsigned long stride,
)source · definition