本文整理汇总了Python中src.graph_utils.rng_target_dist_field方法的典型用法代码示例。如果您正苦于以下问题:Python graph_utils.rng_target_dist_field方法的具体用法?Python graph_utils.rng_target_dist_field怎么用?Python graph_utils.rng_target_dist_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.graph_utils
的用法示例。
在下文中一共展示了graph_utils.rng_target_dist_field方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _gen_rng
# 需要导入模块: from src import graph_utils [as 别名]
# 或者: from src.graph_utils import rng_target_dist_field [as 别名]
def _gen_rng(self, rng):
# instances is a list of list of node_ids.
if self.task_params.move_type == 'circle':
_, _, _, _, paths = rng_target_dist_field(self.task_params.batch_size,
self.task.gtG, rng, 0, 1,
compute_path=True)
instances_ = paths
instances = []
for instance_ in instances_:
instance = instance_
for i in range(self.task_params.num_steps):
instance.append(self.take_action([instance[-1]], [1])[0])
instances.append(instance)
elif self.task_params.move_type == 'shortest_path':
_, _, _, _, paths = rng_target_dist_field(self.task_params.batch_size,
self.task.gtG, rng,
self.task_params.num_steps,
self.task_params.num_steps+1,
compute_path=True)
instances = paths
elif self.task_params.move_type == 'circle+forward':
_, _, _, _, paths = rng_target_dist_field(self.task_params.batch_size,
self.task.gtG, rng, 0, 1,
compute_path=True)
instances_ = paths
instances = []
for instance_ in instances_:
instance = instance_
for i in range(self.task_params.n_ori-1):
instance.append(self.take_action([instance[-1]], [1])[0])
while len(instance) <= self.task_params.num_steps:
while self.take_action([instance[-1]], [3])[0] == instance[-1] and len(instance) <= self.task_params.num_steps:
instance.append(self.take_action([instance[-1]], [2])[0])
if len(instance) <= self.task_params.num_steps:
instance.append(self.take_action([instance[-1]], [3])[0])
instances.append(instance)
# Do random perturbation if needed.
perturbs = _gen_perturbs(rng, self.task_params.batch_size,
self.task_params.num_steps,
self.task_params.data_augment.lr_flip,
self.task_params.data_augment.delta_angle,
self.task_params.data_augment.delta_xy,
self.task_params.data_augment.structured)
return instances, perturbs