TL; DR: You don’t need to normalize your input because fast.ai do it for you.
When you call Databunch.normalize(norm_params)
def normalize(self, stats:Collection[Tensor]=None, do_x:bool=True, do_y:bool=False)->None:
"Add normalize transform using `stats` (defaults to `DataBunch.batch_stats`)"
if getattr(self,'norm',False): raise Exception('Can not call normalize twice')
if stats is None: self.stats = self.batch_stats()
else: self.stats = stats
self.norm,self.denorm = normalize_funcs(*self.stats, do_x=do_x, do_y=do_y)
self.add_tfm(self.norm)
return self
This row self.add_tfm(self.norm)
, add the normalization transform.
So nay time you get an image from the batch it’s normalized.
If you try to use your model (remember that under the hood is a standard pytorch model) without fast.ai, you need to normalize your input manually (and probably reshape it to"size").
NOTE ON TFMS ORDER: the order of transforms is determined by the ‘order’ property, not only the order of original array - ie: resize is always the last one.