Hi,
I need to perform a normalization [0,1] over each channel of a tensor [shape(BxCxWxH)] as a part of the model and I wrote this code:
def normalize_channels(_x, every=True):
    out = torch.ones_like(_x)
    for i in range(_x.shape[0]):
        if every:
            for j in range(_x[i].shape[0]):
                min_ = _x[i][j].min()
                max_ = _x[i][j].max()
                out[i][j].copy_((_x[i][j] - min_) * (1 / (max_ - min_)))
        else:
            min_ = _x[i].min()
            max_ = _x[i].max()
            out.copy_((_x[i] - min_) * (1 / (max_ - min_)))
    return out

but the computational time increases too much. Someone has any ideas on how to improve the performance and how to remove the indexing?