Models module
|
|
|
Implementation of Openmax method |
- class torchosr.models.OSRModule(n_known, lower_stack=None, verbose=False)
Bases:
Module- forward(X)
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- train(dataloader, loss_fn, optimizer)
Sets the module in training mode.
This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g.
Dropout,BatchNorm, etc.- Args:
- mode (bool): whether to set training mode (
True) or evaluation mode (
False). Default:True.
- mode (bool): whether to set training mode (
- Returns:
Module: self
- class torchosr.models.Openmax(lower_stack=None, n_known=3, epsilon=0.5, tail=20, alpha=2)
Bases:
TSoftmaxImplementation of Openmax method
- Parameters:
lower_stack (nn.Sequential) – Network architecture of lower_stack
n_known (int) – Number of known classes
epsilon (float) – Threshold for prediction probability
tail (int) – Tail size for estimating the parameters of Weibull distribution
alpha (int) – Alpha (number of most significant classes to revise)
- train(dataloader, loss_fn, optimizer)
Sets the module in training mode.
This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g.
Dropout,BatchNorm, etc.- Args:
- mode (bool): whether to set training mode (
True) or evaluation mode (
False). Default:True.
- mode (bool): whether to set training mode (
- Returns:
Module: self