std1.0.0-beta-7 SafeC docs

std :: ml::cnn

Struct std::ResidualBlock

#include <std/ml/cnn.h> source

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

§struct Conv2D conv1source
§struct Conv2D conv2source
§struct Conv2D projectionsource

used only when hasProjection

§int hasProjectionsource

Methods

§struct FeatureMap forward(const &FeatureMap input) constsource · definition
§void drop()source · definition
§void free() consumesource · definition

= drop()

§static struct ResidualBlock new( unsigned long inChannels, unsigned long outChannels, unsigned long stride, )source · definition