noisy_model
Classes:
Name | Description |
---|---|
NoisyModel |
Applies a |
NoisyModel
¶
Bases: Module
, Generic[ModuleT, NoiseLayerP, NoiseLayerT]
Applies a BaseNoiseLayer
to a model input Tensor
or a submodule output Tensor
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Callable[NoiseLayerP, NoiseLayerT]
|
The type of |
required |
|
ModuleT
|
The model to apply the |
required |
|
args
|
Positional arguments to |
()
|
|
str | None
|
The name of the |
None
|
|
str | None
|
The name of the |
None
|
|
kwargs
|
Keyword arguments to |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If both |
ValueError
|
If neither |
Methods:
Name | Description |
---|---|
forward |
Call the |
reset_parameters |
Reinitialize parameters and buffers. |
Attributes:
Name | Type | Description |
---|---|---|
target_layer |
Module
|
The |
target_parameter |
str | None
|
The name of the |
target_parameter_index |
int
|
The index of the |
target_layer
property
¶
target_layer: Module
The base_model
submodule whose output Tensor
to transform.
Raises:
Type | Description |
---|---|
ValueError
|
If |
target_parameter
property
¶
target_parameter: str | None
The name of the base_model
input Tensor
argument to transform when target_layer
is None
.
target_parameter_index
cached
property
¶
target_parameter_index: int
The index of the base_model
input Tensor
argument to transform when target_layer
is None
.
forward
¶
Call the base_model
, applying the noise_layer
to the target_parameter
or target_layer
output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Any
|
Positional arguments to |
required |
|
Tensor | None
|
An optional mask that selects the elements of the |
None
|
|
Any
|
Keyword arguments to |
required |
Returns:
Type | Description |
---|---|
Any
|
The result of |
reset_parameters
¶
Reinitialize parameters and buffers.
This method is useful for initializing tensors created on the meta device.