Skip to content

estimators

Classes:

Name Description
Estimator

Defines an interface for estimating noise components from input values.

PatchEstimator

Defines an interface for estimating noise components using non-overlapping 2D convolutions over input image(s).

Estimator

Bases: Generic[ModuleT, OptionalParameterizationT, OptionalMaskerT], Module

Defines an interface for estimating noise components from input values.

Estimators should return a tensor of a broadcastable shape to the input tensor.

Parameters:

Name Type Description Default

module

ModuleT

The module to use to estimate the unparameterized noise component.

required

target_parameter

str

The name of the parameter to pass the input tensor as to the module.

required

parameterization

OptionalParameterizationT

The optional parameterization to apply to the output of module.

None

masker

OptionalMaskerT

The optional masker to apply to the output of the parameterization.

None

Added in version 0.37.0.

Methods:

Name Description
__call__

Estimate noise components from input values.

forward

Estimate noise components from input values.

reset_parameters

Reinitialize parameters and buffers.

__call__

__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]
__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]
__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]
__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]

Estimate noise components from input values.

Parameters:

Name Type Description Default

input

Tensor

The tensor to estimate noise components from.

required

noise_mask

Tensor | None

An optional mask tensor to use to select a subset of the elements of the estimated standard deviations for computing a mask to apply to the input. If None, the mask is computed over all of the estimated standard deviations.

None

kwargs

Any

Additional keyword arguments to module.

required

Returns:

Type Description
tuple[torch.Tensor, torch.Tensor | None]

A tuple containing the estimated noise components and an input mask if there is a masker.

forward

forward(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]

Estimate noise components from input values.

Parameters:

Name Type Description Default

input

Tensor

The tensor to estimate noise components from.

required

noise_mask

Tensor | None

An optional mask tensor to use to select a subset of the elements of the estimated standard deviations for computing a mask to apply to the input. If None, the mask is computed over all of the estimated standard deviations.

None

kwargs

Any

Additional keyword arguments to module.

required

Returns:

Type Description
tuple[torch.Tensor, torch.Tensor | None]

A tuple containing the estimated noise components and an input mask if there is a masker.

reset_parameters

reset_parameters() -> None

Reinitialize parameters and buffers.

This method is useful for initializing tensors created on the meta device.

PatchEstimator

Bases: Estimator[Conv2d, OptionalParameterizationT, OptionalMaskerT]

Defines an interface for estimating noise components using non-overlapping 2D convolutions over input image(s).

Parameters:

Name Type Description Default

module

Conv2d

The 2D convolutional module to use. The estimator must have a stride equal to its kernel size (non-overlapping) and output channels equal to the input channels times the product of the kernel side lengths (input volume = output volume).

required

target_parameter

str

The name of the parameter to pass the input tensor as to the module.

'input'

parameterization

OptionalParameterizationT

The optional parameterization to apply to the output of the estimator.

None

masker

OptionalMaskerT

The optional masker to apply to the output of the parameterization.

None

padding_mode

Literal['constant', 'reflect', 'replicate', 'circular']

Type of padding. One of: constant, reflect, replicate, or circular.

'constant'

padding_value

float

Fill value for constant padding.

0.0

Raises:

Type Description
ValueError

If the stride is not equal to the kernel size.

ValueError

If the output channels are not equal to the input channels times the product of the kernel side lengths.

ValueError

If a non-zero padding value is given for a padding mode other than constant.

Added in version 0.40.0.

Methods:

Name Description
__call__

Estimate noise components from input values.

forward

Estimate noise components from input values.

module_from_input_shape

Construct a non-overlapping Conv2d from the given parameters.

reset_parameters

Reinitialize parameters and buffers.

__call__

__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]
__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]
__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]
__call__(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]

Estimate noise components from input values.

Parameters:

Name Type Description Default

input

Tensor

The tensor to estimate noise components from.

required

noise_mask

Tensor | None

An optional mask tensor to use to select a subset of the elements of the estimated standard deviations for computing a mask to apply to the input. If None, the mask is computed over all of the estimated standard deviations.

None

kwargs

Any

Additional keyword arguments to module.

required

Returns:

Type Description
tuple[torch.Tensor, torch.Tensor | None]

A tuple containing the estimated noise components and an input mask if there is a masker.

forward

forward(
    input: Tensor,
    noise_mask: Tensor | None = None,
    **kwargs: Any,
) -> tuple[torch.Tensor, torch.Tensor | None]

Estimate noise components from input values.

Parameters:

Name Type Description Default

input

Tensor

The tensor to estimate noise components from.

required

noise_mask

Tensor | None

An optional mask tensor to use to select a subset of the elements of the estimated standard deviations for computing a mask to apply to the input. If None, the mask is computed over all of the estimated standard deviations.

None

kwargs

Any

Additional keyword arguments to module.

required

Returns:

Type Description
tuple[torch.Tensor, torch.Tensor | None]

A tuple containing the estimated noise components and an input mask if there is a masker.

module_from_input_shape staticmethod

module_from_input_shape(
    color_channels: int,
    patch_size: int | tuple[int, int] | Sequence[int],
) -> nn.Conv2d

Construct a non-overlapping Conv2d from the given parameters.

Parameters:

Name Type Description Default

color_channels

int

The number of color channels in the input image(s).

required

patch_size

int | tuple[int, int] | Sequence[int]

The dimension of the non-overlapping rectangular patches to tile the image with; if a single value is given, a square patch will be used.

required

Returns:

Type Description
nn.Conv2d

The constructed Conv2d.

reset_parameters

reset_parameters() -> None

Reinitialize parameters and buffers.

This method is useful for initializing tensors created on the meta device.