intprim
Public Member Functions | Public Attributes | List of all members
intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive Class Reference

The BayesianInteractionPrimitive class is responsible for training an Interaction Primitive model from demonstrations as well as performing run-time inference. More...

Inheritance diagram for intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive:

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
 

Detailed Description

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

Constructor & Destructor Documentation

def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.__init__ (   self,
  basis_model,
  scaling_groups = None 
)

The initialization method for BayesianInteractionPrimitives.

Parameters
basis_modelThe basis model corresponding to this state space.
scaling_groupsIf 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.

Parameters
basis_modelThe basis model corresponding to this state space.
scaling_groupsIf provided, used to indicate which degrees of freedom should be scaled as a group.

Member Function Documentation

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.

Parameters
trajectoryMatrix 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.

Parameters
trajectoryMatrix 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.

Parameters
xVector of dimension T containing the phase values that the basis space weights should be projected at.
weightsVector of dimension B containing the basis space weights.
derivTrue if the basis weights should be transformed with basis function derivatives, False for normal basis functions.
Returns
transformed_trajectory Matrix of dimension D x T containing the transformed trajectory.
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.

Parameters
xVector of dimension T containing the phase values that the basis space weights should be projected at.
weightsVector of dimension B containing the basis space weights.
derivTrue if the basis weights should be transformed with basis function derivatives, False for normal basis functions.
Returns
transformed_trajectory Matrix of dimension D x T containing the transformed trajectory.
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.basis_transform (   self,
  trajectory 
)

Transforms the given trajectory from measurement space into the latent basis space.

Parameters
trajectoryMatrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space.
Returns
transformed_state Vector of dimension B containing the transformed trajectory.
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.basis_transform (   self,
  trajectory 
)

Transforms the given trajectory from measurement space into the latent basis space.

Parameters
trajectoryMatrix of dimension D x T containing a demonstration, where T is the number of timesteps and D is the dimension of the measurement space.
Returns
transformed_state Vector of dimension B containing the transformed trajectory.
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.

Parameters
trajectoryMatrix 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.

Parameters
trajectoryMatrix 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.

Parameters
file_nameThe 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.

Parameters
file_nameThe 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.

Parameters
trajectoryMatrix 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_noiseMatrix of dimension D x D containing the observation noise.
active_dofsVector 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_samplesThe 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_phaseThe phase value to start generating the trajectory from. If none, will start generating from the currently estimated phase value.
return_varianceTrue if the phase system mean and variance should be returned. False otherwise.
phase_lookaheadIf phase_lookahead is none, this is an offset that will be applied to the currently estimated phase used to generate the trajectory.
Returns
new_trajectory Matrix of dimension D x num_samples containing the inferred trajectory.
phase Scalar value containing the inferred phase.
mean Vector of dimension B (or N+1+B if return_variance is True) containing the mean of the inferred state.
var Matrix of dimension B x B (or N+1+B x N+1+B if return_variance is True) containing the covariance of the inferred state.
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.

Parameters
trajectoryMatrix 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_noiseMatrix of dimension D x D containing the observation noise.
active_dofsVector 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_samplesThe 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_phaseThe phase value to start generating the trajectory from. If none, will start generating from the currently estimated phase value.
return_varianceTrue if the phase system mean and variance should be returned. False otherwise.
phase_lookaheadIf phase_lookahead is none, this is an offset that will be applied to the currently estimated phase used to generate the trajectory.
Returns
new_trajectory Matrix of dimension D x num_samples containing the inferred trajectory.
phase Scalar value containing the inferred phase.
mean Vector of dimension B (or N+1+B if return_variance is True) containing the mean of the inferred state.
var Matrix of dimension B x B (or N+1+B x N+1+B if return_variance is True) containing the covariance of the inferred state.
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.

Parameters
trajectoryMatrix 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_samplesThe length of the generated approximate trajectory
Returns
approximate_trajectory Matrix of dimension D x num_samples containing the 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.

Parameters
trajectoryMatrix 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_samplesThe length of the generated approximate trajectory
Returns
approximate_trajectory Matrix of dimension D x num_samples containing the 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.

Parameters
trajectoryMatrix 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_samplesThe length of the generated approximate trajectory
Returns
approximate_trajectory Matrix of dimension D x num_samples containing the 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.

Parameters
trajectoryMatrix 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_samplesThe length of the generated approximate trajectory
Returns
approximate_trajectory Matrix of dimension D x num_samples containing the approximate trajectory.
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_basis_weight_parameters (   self)

Gets the mean and covariance for the trained demonstrations.

Returns
mean Vector of dimension B containing the sample mean of the trained basis weights.
var Matrix of dimension B x B containing the sample covariance of the trained basis weights.
def intprim.bayesian_interaction_primitives.BayesianInteractionPrimitive.get_basis_weight_parameters (   self)

Gets the mean and covariance for the trained demonstrations.

Returns
mean Vector of dimension B containing the sample mean of the trained basis weights.
var Matrix of dimension B x B containing the sample covariance of the trained basis weights.
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.

Parameters
num_samplesThe length of the generated mean trajectory
Returns
mean_trajectory Matrix of dimension D x num_samples containing the 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.

Parameters
num_samplesThe length of the generated mean trajectory
Returns
mean_trajectory Matrix of dimension D x num_samples containing the 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.

Parameters
trajectoryMatrix 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_samplesThe length of the generated distribution.
Returns
mean Matrix of dimension D x num_samples containing the mean of the distribution for every degree of freedom.
upper_bound Matrix of dimension D x num_samples containing the mean + std of the distribution for every degree of freedom.
lower_bound Matrix of dimension D x num_samples containing the mean - std of the distribution for every degree of freedom.
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.

Parameters
trajectoryMatrix 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_samplesThe length of the generated distribution.
Returns
mean Matrix of dimension D x num_samples containing the mean of the distribution for every degree of freedom.
upper_bound Matrix of dimension D x num_samples containing the mean + std of the distribution for every degree of freedom.
lower_bound Matrix of dimension D x num_samples containing the mean - std of the distribution for every degree of freedom.
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.

Parameters
file_nameThe 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.

Parameters
file_nameThe 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.

Parameters
filterThe 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.

Parameters
filterThe filter to set.

The documentation for this class was generated from the following file: