How can I extract the mean and variance of a given batch in batchnorm layer, is it the running_mean\running_var just without model.evel()
Thanks a lot!
Running mean would contain the exponential average over previous batches. To get the mean and variance of the current batch you have to compute them using separate functions.
What do you mean by separate functions
Use separate functions to compute mean like torch.mean().
but how can I extract the inputs to the batchnorm
What do you mean?
If you want to get the current
running_var in a pretrained model, use
If you want to get the
running_var in a pretrained model after forward
torch.nn.functional.batch_norm or just forward that layer.
If you donot have a pretrained model, and want to get the
1 then use
I want the mean and the variance of a batch as the normbatch layer calculate
Use torch.mean() and torch.std(). There is also torch.normalize() function that you can look into.
thanks a lot but how can I get the tensor of the batchnorm, X
Hi, have you found a way to do it?