def probs_over_ops(self):
param_len = self.AP_path_alpha.size()[0]
arr = []
arr.append(np.random.uniform(0, 1))
for i in range(param_len - 1):
arr.append(np.random.uniform(0, 1) * (1 - sum(arr)))
probs = np.array(arr)
np.random.shuffle(probs)
probs = torch.from_numpy(probs)
return probs
결과 (CLICK)
난수 뽑는 범위도 매번 random.
def probs_over_ops(self):
param_len = self.AP_path_alpha.size()[0]
arr = []
arr.append(np.random.uniform(0, np.random.uniform(0, 1)))
for i in range(param_len - 1):
arr.append(np.random.uniform(0, np.random.uniform(0, 1)) * (1 - sum(arr)))
probs = np.array(arr)
np.random.shuffle(probs)
probs = torch.from_numpy(probs)
return probs
def probs_over_ops(self):
param_len = self.AP_path_alpha.size()[0]
arr2 = list(np.random.uniform(0, 1, param_len))
sum_arr = sum(arr2)
probs = torch.from_numpy(np.array(list(map(lambda x: x / sum_arr, arr2))))
return probs
이때 normalize를 softmax로 하지 않고 그냥 sum으로 나눠 시행한 이유는, softmax에서는 exponential을 취함에 따라 소수점을 잘 반영하지 못한다고 생각했기 때문.
(softmax에 넣는 값들을 다양하게 하여 실험해 보았었음. 아래 링크 참고 → 그 결과 softmax가 1보다 작은 값인 경우 exponential 함수를 사용함에 따라 편차를 작게 만든다는 문제점이 있다고 생각됨)