Data Types#
- class whobpyt.datatypes.timeseries.Timeseries(data, step_size, modality='')[source]#
- This class is responsible for holding timeseries of empirical and simulated data. It is:
Part of the input and output of Model_fitting and Model_simulation[future].
It is the format expected by the visualization function of whobpyt.
However, the Recording class is not used within and across the NMM and Modals, as a simpler dictionary of tensors is used in those contexts.
Numerical simulation internals don’t necessarily use this data structure, as calculations may be more efficient as the transpose: ts_length x num_regions.
- Attributes:
- dataNumpy Array or Tensor of dimensions num_regions x ts_length
The time series data, either empirical or simulated
- step_sizeFloat
The step size of the time points in the data class
- modalityString
The name of the modality of the time series
- numNodesInt
The number of nodes it time series.
length
IntReturns
- __init__(data, step_size, modality='')[source]#
- Parameters:
- dataNumpy Array or Tensor of dimensions num_regions x ts_length
The time series data, either empirical or simulated
- step_sizeFloat
The step size of the time points in the data class
- modalityString
The name of the modality of the time series
- windowedTensor(TPperWindow)[source]#
This method is called by the Model_fitting Class during training to reshape the data into windowed segments (adds another dimension).
- Parameters:
- TPperWindowInt
The number of time points in the window that will be back propagated
- Returns:
- Tensor: num_windows x num_regions x window_length
The time series data in a windowed format
- class whobpyt.datatypes.parameter.Parameter(val, prior_mean=None, prior_std=None, fit_par=False, asLog=False, asRand=True, lb=0, device=device(type='cpu'))[source]#
- Features of this class:
This class contains a global parameter value or array of values (one per node)
It can also contain associated priors (mean and variance)
It also has attributes for whether the parameter and/or priors should be fit during training
It has a method to return the parameter as numpy value
It has a method to set a random val using based on priors
It has functionality to represent val as log(val) so that during training val will be constrained to be positive
- Attributes:
- valTensor
The parameter value (or an array of node specific parameter values)
- prior_meanTensor
Prior mean of the data value
- prior_precisionTensor
Prior inverse of variance of the value
- fit_par: Bool
Whether the parameter value should be set to as a PyTorch Parameter
- fit_hyperBool
Whether the parameter prior mean and prior variance should be set as a PyTorch Parameter
- asLogBool
Whether the log of the parameter value will be stored instead of the parameter itself (will prevent parameter from being negative).
- __init__(val, prior_mean=None, prior_std=None, fit_par=False, asLog=False, asRand=True, lb=0, device=device(type='cpu'))[source]#
- Parameters:
- valFloat (or Array)
The parameter value (or an array of node specific parameter values)
- prior_meanFloat
Prior mean of the data value
- prior_stdFloat
Prior std of the value
- fit_par: Bool
Whether the parameter value should be set to as a PyTorch Parameter
- device: torch.device
Whether to run on CPU or GPU
- class whobpyt.datatypes.outputs.TrainingStats(model)[source]#
- This class is responsible for recording stats during training (it replaces OutputNM) including:
The training and validation losses over time
The change in model parameters over time
changing hyper parameters over time like learing rates TODO
These are things typically recorded on a per window/epoch basis
- Attributes:
- model_infoDict
Information about model being tracked during training.
- track_paramsList
List of parameter names being tracked during training.
- lossList
A list of loss values over training.
- connectivityList
A list of connectivity values over training.
- leadfieldList
A list of leadfield matrices over training.
- fit_paramsDict
A dictionary of lists where the key is the parameter name and the value is the list of parameter values over training.
- __init__(model)[source]#
- Parameters:
- modelAbstractNMM
A model for which stats will be recorded during training.
- appendLF(newValue)[source]#
Append Lead Field Loss
- Parameters:
- newValueArray
Current state of a lead field matrix being tracked.
- appendLoss(newValue)[source]#
Append Trainig Loss
- Parameters:
- newValueFloat
The loss value of objective function being tracked.
- appendParam(newValues)[source]#
Append Fit Parameters
- Parameters:
- newValuesDict
Dictionary with current states of each model parameter being tracked.
- appendSC(newValue)[source]#
Append Network Connections
- Parameters:
- newValueArray
Current state of the structural connectivity being tracked.
- appendSC_p2e(newValue)[source]#
Append Network Connections
- Parameters:
- newValueArray
Current state of the structural connectivity being tracked.
- appendSC_p2i(newValue)[source]#
Append Network Connections
- Parameters:
- newValueArray
Current state of the structural connectivity being tracked.