pycmtensor.pycmtensor#

PyCMTensor main module

Module Contents#

class pycmtensor.pycmtensor.PyCMTensorModel(db, **kwargs)[source]#

Base model class object

property n_params[source]#

Get the total number of parameters

property n_betas[source]#

Get the count of Beta parameters

property n_weights[source]#

Get the total number of elements of each weight matrix

add_params(params: Union[dict, list])[source]#

Method to load locally defined variables

Parameters:

params (Union[dict, list]) – a dict or list of TensorSharedVariable

add_regularizers(l_reg: aesara.tensor.var.TensorVariable)[source]#

Adds regularizer to model cost function

Parameters:

l_reg (TensorVariable) – symbolic variable defining the regularizer term

get_betas() dict[source]#

Returns the Beta (key, value) pairs as a dict

get_weights() list[numpy.ndarray][source]#

Returns the Weights as a list of matrices

reset_values()[source]#

Resets param values to their initial values

model_loglikelihood()[source]#

Loads the function to self.loglikelihood() to output the loglikelihood value of the model given inputs

model_choice_probabilities()[source]#

Loads the function to self.choice_probabilities() to output discrete choice probabilities. Axes of outputs are swapped

model_choice_predictions()[source]#

Loads the function to self.choice_predictions() to output discrete choice predictions

model_prediction_error()[source]#

Loads the function to self.prediction_error() to output the model error wrt inputs

model_H()[source]#

Loads the function to self.H() to calculate the Hessian matrix or the 2nd-order partial derivatives of the model.

model_BHHH()[source]#

Loads the function to self.BHHH() to calculate the Berndt-Hall-Hall- Hausman (BHHH) approximation.

model_gnorm()[source]#

Loads the function to self.gradient_norm() to calculate the gradient norm of the model cost function.

predict(db, return_choices: bool = True)[source]#

Returns the predicted choice or choice probabilites

Parameters:
  • db (pycmtensor.Data) – database for prediction

  • return_choices (bool) – if True then returns discrete choices instead of probabilities

Returns:

the output vector

Return type:

numpy.ndarray

train(db, **kwargs)[source]#

Function to train the model

Parameters:
  • db (pycmtensor.Data) – database used to train the model

  • **kwargs – keyword arguments for adjusting training configuration. Possible values are max_steps:int, patience:int, lr_scheduler:scheduler.Scheduler, batch_size:int. For more information and other possible options, see hyperparameters

export_to_pickle(f)[source]#

to be removed in 1.4.0