Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Normalize channels separately? #186

Open
vzinche opened this issue Aug 7, 2019 · 0 comments
Open

Normalize channels separately? #186

vzinche opened this issue Aug 7, 2019 · 0 comments

Comments

@vzinche
Copy link
Contributor

vzinche commented Aug 7, 2019

  • inferno version: n/a
  • Python version: n/a
  • Operating System: n/a

Description

inferno/io/trasnform/generic.py
class Normalize(Transform)

def tensor_function(self, tensor):
    mean = np.asarray(tensor.mean()) if self.mean is None else self.mean
    std = np.asarray(tensor.std()) if self.std is None else self.std
    # Figure out how to reshape mean and std
    reshape_as = [-1] + [1] * (tensor.ndim - 1)
    # Normalize
    tensor = (tensor - mean.reshape(*reshape_as))/(std.reshape(*reshape_as) + self.eps)
    return tensor

Issue

I am not sure I'm getting the intentions here, but I guess this reshaping the mean and std part is meant to apply separate means and stds for channels, right?
In this case it looks like it wouldn't work if the mean and std were not supplied as arguments (tensor.mean() would return the mean of a flattened array by default?)
Was it meant like this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant