def course_speed_to_joint_bin(labels):
# each of the labels[i, :] is the course and speed
# convert each pair to the corresponding bin location
course, speed = course_speed_to_discrete(labels)
n = FLAGS.discretize_n_bins
l = len(course)
# follow the convention of speed first and speed second
out = np.zeros((l, n, n), dtype=np.float32)
for i, item in enumerate(zip(course, speed)):
ci, si = item
out[i, ci, si] = 1.0
# do the gaussian smoothing
out[i, :, :] = gaussian_filter(out[i, :, :],
sigma=FLAGS.discretize_label_gaussian_sigma,
mode='constant', cval=0.0)
# renormalization of the distribution
out = out / np.sum(out, axis=(1,2), keepdims=True)
out = np.reshape(out, [l, n*n])
return out
评论列表
文章目录