prfmodel.utils¶
Utility functions.
Attributes¶
Accepted dtypes for prfmodel.typing.Tensor objects. |
Functions¶
|
Convert model parameters in a dataframe into a tensor. |
|
Get the (default) dtype. |
Module Contents¶
- prfmodel.utils.DTYPES¶
Accepted dtypes for prfmodel.typing.Tensor objects.
Accepted dtypes are: “bfloat16”, “float16”, “float32”, and “float64”.
- prfmodel.utils.convert_parameters_to_tensor(parameters: pandas.DataFrame, dtype: str) prfmodel.typing.Tensor[source]¶
Convert model parameters in a dataframe into a tensor.
- Parameters:
parameters (pandas.DataFrame) – Dataframe with columns containing different model parameters and rows containing parameter values for different voxels.
- Returns:
Tensor with the first axis corresponding to voxels and the second axis corresponding to different parameters.
- Return type:
Tensor
Examples
Single parameters:
>>> import pandas as pd >>> params = pd.DataFrame({ >>> "param_1": [0.0, 1.0, 2.0], >>> }) >>> x = convert_parameters_to_tensor(params) >>> print(x.shape) (3, 1)
Multiple parameters:
>>> params = pd.DataFrame({ >>> "param_1": [0.0, 1.0, 2.0], >>> "param_2": [0.0, -1.0, -2.0], >>> }) >>> x = covert_parameters_to_tensor(params) >>> print(x.shape) (3, 2)
- prfmodel.utils.get_dtype(dtype: str | None) str[source]¶
Get the (default) dtype.
Utility function to pass through a dtype or get the default dtype set by keras.config.floatx().
- Parameters:
dtype (str or None) – The dtype to pass through. If None, returns keras.config.floatx().
- Returns:
The dtype.
- Return type:
- Raises:
ValueError – When dtype is not of the values defined in DTYPES.