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
-
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
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 rangemaximum (
float
) – maximum value in human-readable rangecurve (
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\).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]