Shortcuts

torchsynth.parameter

ModuleParameter

class torchsynth.parameter.ModuleParameter(value: Optional[torch.Tensor] = None, parameter_name: str = '', parameter_range: Optional[torchsynth.parameter.ModuleParameterRange] = None, data: Optional[torch.Tensor] = None, requires_grad: bool = True, frozen: Optional[bool] = False)

Bases: torch.nn.parameter.Parameter

ModuleParameter class that inherits from pytorch Parameter

TODO: Rethink value vs data here see https://github.com/torchsynth/torchsynth/issues/101

TODO: parameter_range shouldn’t be optional see https://github.com/torchsynth/torchsynth/issues/340

Parameters
  • value – initial value of this parameter in the human-readable range.

  • parameter_name – A name for this parameter

  • parameter_range – A ModuleParameterRange object that supports conversion between human-readable range and machine-readable [0,1] range.

  • data – directly add data to this parameter in machine-readable range.

  • requires_grad – whether or not a gradient is required for this parameter

  • frozen – freeze parameter value and prevent updating

from_0to1()

Get the value of this parameter in the human-readable range.

TODO ModuleParameterRange should not be optional see https://github.com/torchsynth/torchsynth/issues/340 If no parameter range was specified, then the original parameter is returned.

Return type

Tensor

static is_parameter_frozen(parameter)

Check whether a ModuleParameter is frozen. Asserts that parameter is an instance of ModuleParameter, and returns a bool indicating whether it is frozen.

Parameters

parameter (ModuleParameter) – parameter to check

to_0to1(new_value)

Set the value of this parameter using an input that is in the human-readable range. Raises a runtime error if this parameter has been frozen.

Parameters

new_value (Tensor) – new value to update this parameter with

ModuleParameterRange

class torchsynth.parameter.ModuleParameterRange(minimum, maximum, curve=1, symmetric=False, name=None, description=None)

Bases: object

ModuleParameterRange class is a structure for keeping track of the specific range that a parameter might take on. Also handles functionality for converting between machine-readable range [0, 1] and a human-readable range [minimum, maximum].

Parameters
  • minimum (float) – minimum value in human-readable range

  • maximum (float) – maximum value in human-readable range

  • curve (float) – strictly positive shape of the curve values less than 1 place more emphasis on smaller values and values greater than 1 place more emphasis on larger values. 1 is linear.

  • symmetric (bool) – whether or not the parameter range is symmetric, allows for curves around a center point. When this is True, a curve value of one is linear, greater than one emphasizes the minimum and maximum, and less than one emphasizes values closer to \((maximum - minimum)/2\).

  • name (Optional[str]) – name of this parameter

  • description (Optional[str]) – optional description of this parameter

from_0to1(normalized)

Set value of this parameter using a normalized value in the range [0,1]

Parameters

normalized (Tensor) – value within machine-readable range [0, 1] to convert to human-readable range [minimum, maximum].

Return type

Tensor

to_0to1(value)

Convert from human-readable range [minimum, maximum] to machine-range [0, 1].

Parameters

value (Tensor) – value within the range defined by minimum and maximum

Return type

Tensor

Read the Docs v: stable
Versions
latest
stable
v1.0.1
v1.0.0
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.