本文整理汇总了Python中src.graph_utils.rng_next_goal_rejection_sampling方法的典型用法代码示例。如果您正苦于以下问题:Python graph_utils.rng_next_goal_rejection_sampling方法的具体用法?Python graph_utils.rng_next_goal_rejection_sampling怎么用?Python graph_utils.rng_next_goal_rejection_sampling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.graph_utils
的用法示例。
在下文中一共展示了graph_utils.rng_next_goal_rejection_sampling方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _debug_save_hardness
# 需要导入模块: from src import graph_utils [as 别名]
# 或者: from src.graph_utils import rng_next_goal_rejection_sampling [as 别名]
def _debug_save_hardness(self, seed):
out_path = os.path.join(self.logdir, '{:s}_{:d}_hardness.png'.format(self.building_name, seed))
batch_size = 4000
rng = np.random.RandomState(0)
start_node_ids, end_node_ids, dists, pred_maps, paths, hardnesss, gt_dists = \
rng_next_goal_rejection_sampling(
None, batch_size, self.task.gtG, rng, self.task_params.max_dist,
self.task_params.min_dist, self.task_params.max_dist,
self.task.sampling_distribution, self.task.target_distribution,
self.task.nodes, self.task_params.n_ori, self.task_params.step_size,
self.task.distribution_bins, self.task.rejection_sampling_M)
bins = self.task.distribution_bins
n_bins = self.task.n_bins
with plt.style.context('ggplot'):
fig, axes = utils.subplot(plt, (1,2), (10,10))
ax = axes[0]
_ = ax.hist(hardnesss, bins=bins, weights=np.ones_like(hardnesss)/len(hardnesss))
ax.plot(bins[:-1]+0.5/n_bins, self.task.target_distribution, 'g')
ax.plot(bins[:-1]+0.5/n_bins, self.task.sampling_distribution, 'b')
ax.grid('on')
ax = axes[1]
_ = ax.hist(gt_dists, bins=np.arange(self.task_params.max_dist+1))
ax.grid('on')
ax.set_title('Mean: {:0.2f}, Median: {:0.2f}'.format(np.mean(gt_dists),
np.median(gt_dists)))
with fu.fopen(out_path, 'w') as f:
fig.savefig(f, bbox_inches='tight', transparent=True, pad_inches=0)