本文整理匯總了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