thelper.nn package¶
Neural network and model package.
This package contains classes that define blocks and modules used in various neural network architectures. Most of these classes have been adapted from external sources; see their individual headers for more information.
Subpackages¶
Submodules¶
thelper.nn.common module¶
thelper.nn.coordconv module¶
-
thelper.nn.coordconv.
get_coords_map
(height, width, centered=True, normalized=True, noise=None, dtype=torch.float32)[source]¶ Returns a HxW intrinsic coordinates map tensor (shape=2xHxW).
thelper.nn.densenet module¶
-
thelper.nn.densenet.
densenet121
(pretrained=False, **kwargs)[source]¶ Densenet-121 model from “Densely Connected Convolutional Networks”
- Parameters
pretrained (bool) – If True, returns a model pre-trained on ImageNet
-
thelper.nn.densenet.
densenet161
(pretrained=False, **kwargs)[source]¶ Densenet-161 model from “Densely Connected Convolutional Networks”
- Parameters
pretrained (bool) – If True, returns a model pre-trained on ImageNet
-
thelper.nn.densenet.
densenet169
(pretrained=False, **kwargs)[source]¶ Densenet-169 model from “Densely Connected Convolutional Networks”
- Parameters
pretrained (bool) – If True, returns a model pre-trained on ImageNet
-
thelper.nn.densenet.
densenet201
(pretrained=False, **kwargs)[source]¶ Densenet-201 model from “Densely Connected Convolutional Networks”
- Parameters
pretrained (bool) – If True, returns a model pre-trained on ImageNet
thelper.nn.efficientnet module¶
thelper.nn.fcn module¶
thelper.nn.inceptionresnetv2 module¶
thelper.nn.lenet module¶
thelper.nn.mobilenet module¶
thelper.nn.resnet module¶
thelper.nn.srm module¶
thelper.nn.unet module¶
thelper.nn.utils module¶
Neural network utility functions and classes.
This module contains base interfaces and utility functions used to define and instantiate neural network models.
-
thelper.nn.utils.
create_model
(config, task, save_dir=None, ckptdata=None)[source]¶ Instantiates a model based on a provided task object.
The configuration must be given as a dictionary object. This dictionary will be parsed for a ‘model’ field. This field is expected to be a dictionary itself. It may then specify a type to instantiate as well as the parameters to provide to that class constructor, or a path to a checkpoint from which a model should be loaded.
All models must derive from
thelper.nn.utils.Module
, or they must be instantiable throughthelper.nn.utils.ExternalModule
(or one of its specialized classes). The provided task object will be used to make sure that the model has the required input/output layers for the requested objective.If checkpoint data is provided by the caller, the weights it contains will be loaded into the returned model.
Usage examples inside a session configuration file:
# ... # the function will look for a 'model' field in the provided config dict "model": { # the type provides the class name to instantiate an object from "type": "thelper.nn.mobilenet.MobileNetV2", # the parameters listed below are passed to the model's constructor "params": { # ... } # ...
- Parameters
config – a session dictionary that provides a ‘model’ field containing a dictionary.
task – a task object that will be passed to the model’s constructor in order to specialize it. Can be
None
if a checkpoint is provided, and if the previous task is wanted instead of a new one.save_dir – if not
None
, a log file containing model information will be created there.ckptdata – raw checkpoint data loaded via
torch.load()
; the model will be given its previous state.
- Returns
The instantiated model, compatible with the interface of both
thelper.nn.utils.Module
andtorch.nn.Module
.
See also
thelper.nn.utils.Module
thelper.nn.utils.ExternalModule