intprim
|
The BayesianInteractionPrimitive class is responsible for training an Interaction Primitive model from demonstrations as well as performing run-time inference. More...
Public Member Functions | |
def | __init__ (self, basis_model, scaling_groups=None) |
The initialization method for BayesianInteractionPrimitives. More... | |
def | export_data (self, file_name) |
Exports the internal state information from this model. More... | |
def | import_data (self, file_name) |
Imports the internal state information from an export file. More... | |
def | init_scalers (self) |
Internal method which initializes data scalers. | |
def | compute_standardization (self, trajectory) |
Iteratively fits data scalers. More... | |
def | add_demonstration (self, trajectory) |
Iteratively adds a demonstration to the model. More... | |
def | get_mean_trajectory (self, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES) |
Gets the mean trajectory of all trained demonstrations. More... | |
def | get_approximate_trajectory (self, trajectory, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES, deriv=False) |
Gets the approximated trajectory for the given demonstration. More... | |
def | get_approximate_trajectory_derivative (self, trajectory, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES) |
Gets the approximated trajectory derivative for the given demonstration. More... | |
def | get_probability_distribution (self, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES) |
Gets the probability distribution of the trained demonstrations. More... | |
def | basis_transform (self, trajectory) |
Transforms the given trajectory from measurement space into the latent basis space. More... | |
def | basis_inverse_transform (self, x, weights, deriv=False) |
Transforms the given basis space weights to measurement space for the given phase values. More... | |
def | get_basis_weight_parameters (self) |
Gets the mean and covariance for the trained demonstrations. More... | |
def | generate_probable_trajectory_recursive (self, trajectory, observation_noise, active_dofs, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES, starting_phase=None, return_variance=False, phase_lookahead=0.0) |
Performs inference over the given trajectory and returns the most probable future trajectory. More... | |
def | set_filter (self, filter) |
Sets the given filter as the current filter. More... | |
def | __init__ (self, basis_model, scaling_groups=None) |
The initialization method for BayesianInteractionPrimitives. More... | |
def | export_data (self, file_name) |
Exports the internal state information from this model. More... | |
def | import_data (self, file_name) |
Imports the internal state information from an export file. More... | |
def | init_scalers (self) |
Internal method which initializes data scalers. | |
def | compute_standardization (self, trajectory) |
Iteratively fits data scalers. More... | |
def | add_demonstration (self, trajectory) |
Iteratively adds a demonstration to the model. More... | |
def | get_mean_trajectory (self, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES) |
Gets the mean trajectory of all trained demonstrations. More... | |
def | get_approximate_trajectory (self, trajectory, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES, deriv=False) |
Gets the approximated trajectory for the given demonstration. More... | |
def | get_approximate_trajectory_derivative (self, trajectory, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES) |
Gets the approximated trajectory derivative for the given demonstration. More... | |
def | get_probability_distribution (self, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES) |
Gets the probability distribution of the trained demonstrations. More... | |
def | basis_transform (self, trajectory) |
Transforms the given trajectory from measurement space into the latent basis space. More... | |
def | basis_inverse_transform (self, x, weights, deriv=False) |
Transforms the given basis space weights to measurement space for the given phase values. More... | |
def | get_basis_weight_parameters (self) |
Gets the mean and covariance for the trained demonstrations. More... | |
def | generate_probable_trajectory_recursive (self, trajectory, observation_noise, active_dofs, num_samples=intprim.constants.DEFAULT_NUM_SAMPLES, starting_phase=None, return_variance=False, phase_lookahead=0.0) |
Performs inference over the given trajectory and returns the most probable future trajectory. More... | |
def | set_filter (self, filter) |
Sets the given filter as the current filter. More... | |
Public Attributes | |
basis_model | |
scaling_groups | |
basis_weights | |
filter | |
prior_fitted | |
scalers | |
The BayesianInteractionPrimitive class is responsible for training an Interaction Primitive model from demonstrations as well as performing run-time inference.
Support for importing and exporting a trained model as well
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.__init__ | ( | self, | |
basis_model, | |||
scaling_groups = None |
|||
) |
The initialization method for BayesianInteractionPrimitives.
basis_model | The basis model corresponding to this state space. |
scaling_groups | If provided, used to indicate which degrees of freedom should be scaled as a group. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.__init__ | ( | self, | |
basis_model, | |||
scaling_groups = None |
|||
) |
The initialization method for BayesianInteractionPrimitives.
basis_model | The basis model corresponding to this state space. |
scaling_groups | If provided, used to indicate which degrees of freedom should be scaled as a group. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.add_demonstration | ( | self, | |
trajectory | |||
) |
Iteratively adds a demonstration to the model.
The demonstration is decomposed into the latent space and the weights are stored internally.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.add_demonstration | ( | self, | |
trajectory | |||
) |
Iteratively adds a demonstration to the model.
The demonstration is decomposed into the latent space and the weights are stored internally.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.basis_inverse_transform | ( | self, | |
x, | |||
weights, | |||
deriv = False |
|||
) |
Transforms the given basis space weights to measurement space for the given phase values.
x | Vector of dimension T containing the phase values that the basis space weights should be projected at. |
weights | Vector of dimension B containing the basis space weights. |
deriv | True if the basis weights should be transformed with basis function derivatives, False for normal basis functions. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.basis_inverse_transform | ( | self, | |
x, | |||
weights, | |||
deriv = False |
|||
) |
Transforms the given basis space weights to measurement space for the given phase values.
x | Vector of dimension T containing the phase values that the basis space weights should be projected at. |
weights | Vector of dimension B containing the basis space weights. |
deriv | True if the basis weights should be transformed with basis function derivatives, False for normal basis functions. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.basis_transform | ( | self, | |
trajectory | |||
) |
Transforms the given trajectory from measurement space into the latent basis space.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.basis_transform | ( | self, | |
trajectory | |||
) |
Transforms the given trajectory from measurement space into the latent basis space.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.compute_standardization | ( | self, | |
trajectory | |||
) |
Iteratively fits data scalers.
This must be called on all training demonstrations before fitting, if scaling is used.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.compute_standardization | ( | self, | |
trajectory | |||
) |
Iteratively fits data scalers.
This must be called on all training demonstrations before fitting, if scaling is used.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.export_data | ( | self, | |
file_name | |||
) |
Exports the internal state information from this model.
Allows one to export a trained model and import it again without requiring training.
file_name | The name of the export file. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.export_data | ( | self, | |
file_name | |||
) |
Exports the internal state information from this model.
Allows one to export a trained model and import it again without requiring training.
file_name | The name of the export file. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.generate_probable_trajectory_recursive | ( | self, | |
trajectory, | |||
observation_noise, | |||
active_dofs, | |||
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES , |
|||
starting_phase = None , |
|||
return_variance = False , |
|||
phase_lookahead = 0.0 |
|||
) |
Performs inference over the given trajectory and returns the most probable future trajectory.
This is a recursive call and the internal state of the currently set filter will be updated, so only new observations should be passed to this method each time it is called.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
observation_noise | Matrix of dimension D x D containing the observation noise. |
active_dofs | Vector of dimension \( D_o \) containing measurement space indices of the observed degrees of freedom. Note that the measurements will also contain unobserved degrees of freedom, but their values should not be used for inference. |
num_samples | The length of the generated trajectory. If set to 1, only a single value at the current or specified phase (see starting_phase) is generated. |
starting_phase | The phase value to start generating the trajectory from. If none, will start generating from the currently estimated phase value. |
return_variance | True if the phase system mean and variance should be returned. False otherwise. |
phase_lookahead | If phase_lookahead is none, this is an offset that will be applied to the currently estimated phase used to generate the trajectory. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.generate_probable_trajectory_recursive | ( | self, | |
trajectory, | |||
observation_noise, | |||
active_dofs, | |||
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES , |
|||
starting_phase = None , |
|||
return_variance = False , |
|||
phase_lookahead = 0.0 |
|||
) |
Performs inference over the given trajectory and returns the most probable future trajectory.
This is a recursive call and the internal state of the currently set filter will be updated, so only new observations should be passed to this method each time it is called.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
observation_noise | Matrix of dimension D x D containing the observation noise. |
active_dofs | Vector of dimension \( D_o \) containing measurement space indices of the observed degrees of freedom. Note that the measurements will also contain unobserved degrees of freedom, but their values should not be used for inference. |
num_samples | The length of the generated trajectory. If set to 1, only a single value at the current or specified phase (see starting_phase) is generated. |
starting_phase | The phase value to start generating the trajectory from. If none, will start generating from the currently estimated phase value. |
return_variance | True if the phase system mean and variance should be returned. False otherwise. |
phase_lookahead | If phase_lookahead is none, this is an offset that will be applied to the currently estimated phase used to generate the trajectory. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_approximate_trajectory | ( | self, | |
trajectory, | |||
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES , |
|||
deriv = False |
|||
) |
Gets the approximated trajectory for the given demonstration.
This is obtained by transforming the demonstration to the latent space and then projecting it back to measurement space.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
num_samples | The length of the generated approximate trajectory |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_approximate_trajectory | ( | self, | |
trajectory, | |||
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES , |
|||
deriv = False |
|||
) |
Gets the approximated trajectory for the given demonstration.
This is obtained by transforming the demonstration to the latent space and then projecting it back to measurement space.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
num_samples | The length of the generated approximate trajectory |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_approximate_trajectory_derivative | ( | self, | |
trajectory, | |||
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES |
|||
) |
Gets the approximated trajectory derivative for the given demonstration.
This is obtained by transforming the demonstration to a latent space composed of the basis function derivatives and then projecting it back to measurement space.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
num_samples | The length of the generated approximate trajectory |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_approximate_trajectory_derivative | ( | self, | |
trajectory, | |||
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES |
|||
) |
Gets the approximated trajectory derivative for the given demonstration.
This is obtained by transforming the demonstration to a latent space composed of the basis function derivatives and then projecting it back to measurement space.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
num_samples | The length of the generated approximate trajectory |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_basis_weight_parameters | ( | self | ) |
Gets the mean and covariance for the trained demonstrations.
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_basis_weight_parameters | ( | self | ) |
Gets the mean and covariance for the trained demonstrations.
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_mean_trajectory | ( | self, | |
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES |
|||
) |
Gets the mean trajectory of all trained demonstrations.
num_samples | The length of the generated mean trajectory |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_mean_trajectory | ( | self, | |
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES |
|||
) |
Gets the mean trajectory of all trained demonstrations.
num_samples | The length of the generated mean trajectory |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_probability_distribution | ( | self, | |
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES |
|||
) |
Gets the probability distribution of the trained demonstrations.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
num_samples | The length of the generated distribution. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_probability_distribution | ( | self, | |
num_samples = intprim.constants.DEFAULT_NUM_SAMPLES |
|||
) |
Gets the probability distribution of the trained demonstrations.
trajectory | Matrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space. |
num_samples | The length of the generated distribution. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.import_data | ( | self, | |
file_name | |||
) |
Imports the internal state information from an export file.
Allows one to import a trained model without requiring training.
file_name | The name of the import file. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.import_data | ( | self, | |
file_name | |||
) |
Imports the internal state information from an export file.
Allows one to import a trained model without requiring training.
file_name | The name of the import file. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.set_filter | ( | self, | |
filter | |||
) |
Sets the given filter as the current filter.
This is used to initialize and reset the filter between interactions.
filter | The filter to set. |
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.set_filter | ( | self, | |
filter | |||
) |
Sets the given filter as the current filter.
This is used to initialize and reset the filter between interactions.
filter | The filter to set. |