Model module
Created on 12/14/2021 Base model class
Author: dzhi, jdiedrichsen
- class model.Model[source][source]
Abstract class for models Implements two behaviors:
- param_list: These is the list of free parameters.
the class allows vectorization of free parameters, sets param_size and nparams automatically, and tells you where to find the parameters in the vector
- tmp_list: List of data-specific attributes that should not be copied
or saved. when deep_copy is called on a model, these items will only be copied by reference (id), but not copied in memory. When clear is call, the reference to these items will be deleted (but not the data itself, if it is referenced from somewhere else).
- clear()[source][source]
Removes any member of tmp_list from the model This is important when saving model fits.
- get_param_indices(name)[source][source]
Returns the indices for specific set of parameters :param names: parameter names to returns indices for :type names: str
- Returns:
indices (nparray)
- get_params()[source][source]
Returns the vectorized version of the parameters :Returns: theta (1-d np.array) – Vectorized version of parameters
- move_to(device='cpu')[source][source]
move all torch.Tensor object in Model class to the target device
- Parameters:
M (Model) – Model object
device (str or pt.device) – the target device to store the tensor default - ‘cpu’
- Returns:
None
Notes
This function works generally for all Models but is not recursive