Observer#

class Observer(dtype, **kwargs)[source]#

A base class for Observer Module. Used to record input tensor’s statistics for quantization.

Parameters:

dtype (Union[str, QuantDtypeMeta]) – a string indicating which dtype to collect scale and zero_point of.

train(mode=True, recursive=True)[source]#

Sets training mode of all the modules within this module (including itself) to mode. This effectively sets the training attributes of those modules to mode, but only has effect on certain modules (e.g. BatchNorm2d, Dropout, Observer)

Parameters:
  • mode (bool) – the training mode to be set on modules.

  • recursive (bool) – whether to recursively call submodules’ train().

Return type:

None