parameter#
Utility to splice (flatten) and merge (unflatten) complex parameters for βreal-onlyβ optimizers.
- class ParameterFlattener(parameters: Mapping[str, ParameterValue])[source]#
Bases:
objectUtility-class to flatten complex parameters.
- Parameters:
parameters β Original parameter-dictionary (unflattened). Non-complex values will not be affected by any method.
- unflatten(flattened_parameters: dict[str, float]) dict[str, TypeAliasForwardRef('tensorwaves.interface.ParameterValue')][source]#
Reverse the flattening operation.
Takes a parameter-dictionary and merges all real and imaginary values whose respective keys have been registered in the constructor of the
ParameterFlattenerinto a complex number. Specifically, while this works also on inputs which have not been generated byflatten()their outputs might be unexpected.- Parameters:
flattened_parameters β parameter
dictwhose values are to be unflattened.
- flatten(parameters: Mapping[str, ParameterValue]) dict[str, float][source]#
Flatten the parameter-values whose keys have been registered in the constructor.
Splits all complex values whose keys have been registered in the constructor of
ParameterFlattenerinto their real and imaginary parts. Their keys are predetermined by the constructor. Other key-value pairs remain unchanged.- Parameters:
parameters β parameter
dictwhose values are to be flattened.