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