tbp.monty.experiment#

tbp.monty.experiment.environment#

tbp.monty.experiment.learning_module#

class ExperimentLearningModule(*args, **kwargs)[source]#

Bases: Protocol

Experiment interface to a Learning Module.

__init__(*args, **kwargs)#
fixme_reset_ground_truth(primary_target=None) None[source]#

Reset internal state based on ground truth.

Parameters:

primary_target – The primary target for the learning module to recognize.

Return type:

None

fixme_update_ground_truth() None[source]#

Update internal state based on ground truth.

Return type:

None

reset_stm() None[source]#

Reset short-term memory buffer.

Do things like reset buffers or possible_matches before training.

Return type:

None

set_experiment_mode(mode: ExperimentMode) None[source]#

Set the experiment mode.

Update state variables based on which method (train or evaluate) is being called at the experiment level.

Parameters:

mode (ExperimentMode) – The experiment mode.

Return type:

None

update_ltm_from_stm() None[source]#

Update long-term memory from short-term memory buffer.

Return type:

None

property recognition_status: RecognitionStatus#

tbp.monty.experiment.match_criteria#

class AnyLMsMatch(count: int) None[source]#

Bases: MatchCriterion

Satisifed once any count of learning modules have reached “match”.

__init__(count: int) None[source]#

Initialize the criterion.

Parameters:

count (int) – The number of learning modules that must reach “match” for the criterion to be satisfied.

Raises:

ValueError – If count is not positive.

class MatchCriterion(*args, **kwargs)[source]#

Bases: Protocol

Decides whether learning modules have collectively matched the target.

An individual learning module reaches its own terminal state independently of the others. The match criterion turns those per-LM terminal states into the single system-level decision of whether Monty has recognized the object.

__init__(*args, **kwargs)#
class NamedLMsMatch(ids: list[str]) None[source]#

Bases: MatchCriterion

Satisifed once all learning modules with the given IDs have reached “match”.

__init__(ids)[source]#

Initialize the criterion.

Parameters:

ids – The IDs of the learning modules that must reach “match” for the criterion to be satisfied.

Raises:

ValueError – If ids is empty.

tbp.monty.experiment.monty#

class ExperimentMonty(*args, **kwargs)[source]#

Bases: Protocol

Experiment interface to Monty model.

__init__(*args, **kwargs)#
fixme_set_ground_truth(primary_target: dict[str, Any] | None = None, semantic_id_to_label: dict[SemanticID, str] | None = None) None[source]#

Provide ground truth from experiment supervision.

Parameters:
  • primary_target – Optional primary target to recognize.

  • semantic_id_to_label – Optional mapping from IDs to labels.

is_done() bool[source]#

Return True if the model has reached a terminal condition.

Return type:

bool

reset() None[source]#

Reset the internal state of this Monty model.

Return type:

None

set_experiment_mode(mode: ExperimentMode) None[source]#

Set the experiment mode.

Update state variables based on which method (train or evaluate) is being called at the experiment level.

Parameters:

mode (ExperimentMode) – The experiment mode.

Return type:

None

update_ltm() None[source]#

Transfer short-term buffer to long-term memory.

Return type:

None

tbp.monty.experiment.motor_system#

class ExperimentMotorPolicy(*args, **kwargs)[source]#

Bases: Protocol

Experiment interface to a Motor Policy.

__init__(*args, **kwargs)#
fixme_provide_motor_system(motor_system: ExperimentMotorSystem) None[source]#

Provide access to the Motor System during initialization.

This is part of the work to remove reset() in favor or Hydra instantiation. It is used to provide a reference to the Motor System so the SurfacePolicy and its subclasses can override the motor_only_step property.

TODO: This whole mechanism is a hack for the benefit of SurfacePolicy et. al. What we should be doing is supporting more complex actions, like “follow surface in this direction,” whose details are left to the simulator.

Parameters:

motor_system (ExperimentMotorSystem) – The associated Motor System.

Return type:

None

reset() None[source]#

Reset the internal state of this Motor Policy.

Return type:

None

class ExperimentMotorPolicySelector(*args, **kwargs)[source]#

Bases: Protocol

Experiment interface to a Motor Policy Selector.

__init__(*args, **kwargs)#
fixme_provide_motor_system(motor_system: ExperimentMotorSystem) None[source]#

Provide access to the Motor System during initialization.

This is part of the work to remove reset() in favor or Hydra instantiation. It is used to provide a reference to the Motor System so the SurfacePolicy and its subclasses can override the motor_only_step property.

TODO: This whole mechanism is a hack for the benefit of SurfacePolicy et. al. What we should be doing is supporting more complex actions, like “follow surface in this direction,” whose details are left to the simulator.

Parameters:

motor_system (ExperimentMotorSystem) – The associated Motor System.

Return type:

None

reset() None[source]#

Reset the internal state of this Motor Policy Selector.

Return type:

None

class ExperimentMotorSystem(*args, **kwargs)[source]#

Bases: Protocol

Experiment interface to a Motor System.

__init__(*args, **kwargs)#
reset() None[source]#

Reset the internal state of this Motor System.

Return type:

None

property motor_only_step: bool#

When True, suppress Learning Module processing.

tbp.monty.experiment.recognition_policy#

class AnyPolicy(policies: Sequence[RecognitionPolicy]) None[source]#

Bases: RecognitionPolicy

Combine multiple terminal conditions for Experiments.

Terminal condition is reached if _any_ RecognitionPolicy says so.

__init__(policies: Sequence[RecognitionPolicy]) None[source]#

Initialize the policy.

Parameters:

policies (Sequence[RecognitionPolicy]) – The policies to check (in order).

Raises:

ValueError – If len(policies) < 1.

class MaxTotalSteps(max_total_steps: int) None[source]#

Bases: RecognitionPolicy

step >= max_total_steps.

__init__(max_total_steps: int) None[source]#

Initialize the policy.

Parameters:

max_total_steps (int) – The maximum number of steps before terminating the episode.

Raises:

ValueError – If max_total_steps is not positive.

class MaximumSteps(max_train_steps: int, max_eval_steps: int) None[source]#

Bases: RecognitionPolicy

step >= {max_train_steps | max_eval_steps} or model.is_done.

Terminal conditions include: - step >= {max_train_steps | max_eval_steps} - model.is_done

__init__(max_train_steps: int, max_eval_steps: int) None[source]#

Initialize the policy.

Parameters:
  • max_train_steps (int) – The maximum steps to take in training mode.

  • max_eval_steps (int) – The maximum steps to take in evaluation mode.

Raises:

ValueError – If max_train_steps, or max_eval_steps are not positive.

class MinimumLMs(min_lms: int, max_train_steps: int, max_eval_steps: int) None[source]#

Bases: RecognitionPolicy

min_lms have reached a conclusion.

Terminal conditions include: - num_matched >= self._min_lms - count.step >= {max_train_steps | max_eval_steps}

__init__(min_lms: int, max_train_steps: int, max_eval_steps: int) None[source]#

Initialize the policy.

Parameters:
  • min_lms (int) – The number of Learning Modules that must reach a conclusion for the policy to be satisfied.

  • max_train_steps (int) – The maximum steps to take in training mode.

  • max_eval_steps (int) – The maximum steps to take in evaluation mode.

Raises:

ValueError – If min_lms, max_train_steps, or max_eval_steps are not positive.

class MontyIsDone(*args, **kwargs)[source]#

Bases: RecognitionPolicy

Legacy (default) policy.

class NaiveScan(max_total_steps: int, fixed_amount: int) None[source]#

Bases: RecognitionPolicy

count.steps >= count.max_total_steps or model.is_done.

The step limit also accounts for the number of steps the Naive Scan motor policy takes before its spiral completes.

__init__(max_total_steps: int, fixed_amount: int) None[source]#

Initialize the policy.

Parameters:
  • max_total_steps (int) – The maximum number of steps before terminating the episode.

  • fixed_amount (int) – The Naive Scan step size.

Raises:

ValueError – If max_total_steps or fixed_amount are not positive.

class ObjectRecognition(max_train_steps: int, max_eval_steps: int, max_total_steps: int) None[source]#

Bases: RecognitionPolicy

Determine terminal conditions for object recognition experiments.

Terminal conditions include: - model.matching_steps >= {max_train_steps | max_eval_steps} - count.step >= max_total_steps - model.is_done

__init__(max_train_steps: int, max_eval_steps: int, max_total_steps: int) None[source]#

Initialize the policy.

Parameters:
  • max_train_steps (int) – The maximum steps to take in training mode.

  • max_eval_steps (int) – The maximum steps to take in evaluation mode.

  • max_total_steps (int) – The maximum total number of steps before terminating.

Raises:

ValueError – If max_train_steps, max_eval_steps, or max_total_steps are not positive.

class RecognitionCounter(step: int = 0, mode: ExperimentMode = ExperimentMode.EVAL) None[source]#

Bases: object

Experiment counters and limits.

__init__(step: int = 0, mode: ExperimentMode = ExperimentMode.EVAL) None#
mode: ExperimentMode = 'eval'#

The stepping mode (traning or evaluation).

step: int = 0#

The current step number.

class RecognitionPolicy(*args, **kwargs)[source]#

Bases: Protocol

Decides what constitutes “recognition” in an Experiment.

Each Learning Module determines its own Recognition Status independently of the others. The Recognition Policy turns the per-LM status into the single decision of whether Monty has recognized the object.

__init__(*args, **kwargs)#
class RecognitionResult(is_done: bool) None[source]#

Bases: object

Aggregated result from the Recognition Policy.

__init__(is_done: bool) None#
is_done: bool#

tbp.monty.experiment.recognition_status#

class RecognitionConclusion(value)[source]#

Bases: Enum

Label for the terminal state of a Learning Module.

MATCH = 'match'#
NO_MATCH = 'no_match'#
TIME_OUT = 'time_out'#
class RecognitionStatus(conclusion: RecognitionConclusion | None = None, telemetry: dict[str, Any] = <factory>) None[source]#

Bases: object

Recognition Status from each Learning Module.

__init__(conclusion: RecognitionConclusion | None = None, telemetry: dict[str, Any] = <factory>) None#
conclusion: RecognitionConclusion | None = None#
telemetry: dict[str, Any]#

tbp.monty.experiment.sensor_module#

class ExperimentSensorModule(*args, **kwargs)[source]#

Bases: Protocol

Experiment interface to a Sensor Module.

__init__(*args, **kwargs)#
reset() None[source]#

Reset the internal state of this Sensor Module.

Return type:

None