affine = False is equivalent to simply computing:
y = (x - mu) / sqrt(var + eps)
where, mu is the running (propagated) mean and var is the running (propagated) variance. Equivalently, this can be interpreted as fixing gamma=1 and beta=0 (These will then be non-trainable. Since they don’t appear in the equation above, no gradients will be calculated for those).
If you rather want to initialize gamma, beta to (1, 0) and train them, you’d want to perform something like:
bn = nn.BatchNorm1d(num_c, affine=True)
bn.weight = 1
bn.bias = 0