本文整理汇总了Python中memory.Memory.on_input方法的典型用法代码示例。如果您正苦于以下问题:Python Memory.on_input方法的具体用法?Python Memory.on_input怎么用?Python Memory.on_input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类memory.Memory
的用法示例。
在下文中一共展示了Memory.on_input方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DimensionalityReductionExperiment
# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import on_input [as 别名]
#.........这里部分代码省略.........
Experiment.ui_disconnected(self, handler)
self._improvise_params.remove_listener(self._send_changed_parameter)
if self.args.enable_features:
self._imitate_params.remove_listener(self._send_changed_parameter)
self._hybrid_params.remove_listener(self._send_changed_parameter)
def _add_parameters_listener(self, parameters):
parameters.add_listener(self._send_changed_parameter)
parameters.notify_changed_all()
def _send_changed_parameter(self, parameter):
self.send_event_to_ui(Event(
Event.PARAMETER,
{"class": parameter.parameters.__class__.__name__,
"name": parameter.name,
"value": parameter.value()}))
def _handle_mode_event(self, event):
self._mode = event.content
def _handle_reduction(self, event):
new_reduction = event.content
if self.reduction is None or not numpy.array_equal(new_reduction, self.reduction):
self.reduction = new_reduction
for behavior in self._behaviors:
behavior.set_reduction(self.reduction)
self.send_event_to_ui(event)
def _update_using_behavior(self, behavior):
self._potentially_update_reduction_using_behavior(behavior)
self._update_entity_root_vertical_orientation_using_behavior(behavior)
def _potentially_update_reduction_using_behavior(self, behavior):
behavior.on_input(self.input)
new_reduction = behavior.get_reduction()
if new_reduction is not None and (
self.reduction is None or not numpy.array_equal(new_reduction, self.reduction)):
self.reduction = new_reduction
for other_behavior in self._behaviors:
if other_behavior != behavior:
behavior.set_reduction(self.reduction)
self.send_event_to_ui(Event(Event.REDUCTION, self.reduction))
def _update_entity_root_vertical_orientation_using_behavior(self, behavior):
self.entity.modified_root_vertical_orientation = behavior.get_root_vertical_orientation()
def add_parser_arguments_second_pass(self, parser, args):
dimensionality_reduction_class = DimensionalityReductionFactory.get_class(args.reduction_type)
dimensionality_reduction_class.add_parser_arguments(parser)
def needs_training_data(self):
return self.args.enable_follow
def run(self):
dimensionality_reduction_class = DimensionalityReductionFactory.get_class(self.args.reduction_type)
num_input_dimensions = self.entity.get_value_length()
self.student = dimensionality_reduction_class(
num_input_dimensions, self.args.num_components, self.args)
if self.args.training_data_stats:
self._prepare_training_data()
self._print_training_data_stats()
if self.args.train:
self._prepare_training_data()
self._train_model()