代码拉取完成,页面将自动刷新
import numpy as np
def gaussian_kernel(distance_matrix, sigma):
return np.exp(-distance_matrix / (2 * sigma ** 2))
# temp_dist = np.array([[0.5, 1, 2],
# [0.7, 4, 3],
# [2, 3, 0.6]]
# )
temp_dist = np.array([[2.2796936e+00, 1.4185905e-04, 2.1287000e+00, 1.8230720e+00, 2.0047464e+00, 1.9925015e+00],
[1.8264387e+00, 2.2247264e+00, 2.1148393e+00, 1.8682027e+00, 2.1857731e+00, 2.0481849e+00],
[2.1379218e+00, 1.7820594e+00, 1.9546708e+00, 2.1857350e+00, 2.2835042e+00, 2.2263017e+00],
[1.7801874e+00, 1.9467703e+00, 1.7516470e+00, 1.5445557e+00, 2.1465287e+00, 1.7326559e+00],
[1.3039300e+00, 1.8856990e+00, 2.0850537e+00, 1.8263741e+00, 1.9664614e+00, 1.2030802e+00],
[6.8809760e-01, 1.9833440e+00, 2.0243869e+00, 2.1859434e+00, 2.1319501e+00, 1.6423464e-03]])
temp_min = np.min(temp_dist, axis=1)
index1 = np.where(temp_min < 0.6)[0]
weight1 = temp_dist[index1,:].mean(axis=0)
weight1 = 1.0/(weight1 + 0.01)
weight1 = weight1/np.sum(weight1)
gaus_dist = gaussian_kernel(temp_dist, sigma=0.9)
gaus_max = np.max(gaus_dist, axis=1)
index2 = np.where(gaus_max > 0.6)[0]
weight2 = gaus_dist[index2,:].mean(axis=0)
weight2 = weight2/np.sum(weight2)
print(gaus_dist)
print('------temp------')
print(temp_min)
print(index1)
print(weight1)
print('------gaus-------')
print(gaus_max)
print(index2)
print(weight2)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。