I wanted to ask a question about normalizing inputs.
Where would you implement custom normalizing functions, for instance I have a type of input that could be normalized in various ways (std-mean, polar-coordinates, etc…), but would like to retain the automatic
denorm to visualize the inputs.
So my options are:
- Creating a
PreProcessor to normalize inputs, how I would
normalize in a custom
- Just normalizing before giving data to fastai.
Check the source of
fastai.vision.data.ImageDataBunch.normalize in particular:
self.norm,self.denorm = normalize_funcs(*self.stats, do_x=do_x, do_y=do_y)
So you should be able to just add your own
norm/denorm functions and add
norm as a transform and fastai will call them.
what if I want to implement:
It doesn’t have to be a databunch method. You can have:
def polar_norm(db:ImageDataBunch, stats):
db.norm = partial(do_polar_norm, stats=stats)
db.denorm = partial(do_polar_denorm, stats=stats)
And so on for others. Check the
normalize_funcs for how the
do_* functions should work, it’s just returning a pair of norm/denorm functions.
Though the above would also work as a databunch method. In fact you could just add
ImageDataBunch.polar_norm = polar_norm at the end of the above code and then any
ImageDataBunch would have that