for 루프에서 벡터화 된 numpy 조작으로의 아주 간단한 전환에서 버그를 알아낼 수 없습니다. 코드는 다음과 같은python for-loop와 3 차원 numpy 행렬 추가 사이의 동일성
for null_pos in null_positions:
np.add(singletree[null_pos, parent.x, :, :],
posteriors[parent.u, null_pos, :, :],
out=singletree[null_pos, parent.x, :, :])
는 2D 매트릭스 사이의 간단한 추가이기 때문에, 내가이 3D 또한 것은이
np.add(singletree[null_positions, parent.x, :, :],
posteriors[parent.u, null_positions, :, :],
out=singletree[null_positions, parent.x, :, :])
로 일반화, 결과가 차이가 나타납니다! 왜 그걸 볼 수 있니?
감사합니다!
는업데이트 :
singletree[null_positions, parent.x, :, :] = \
posteriors[parent.u, null_positions, :, :] +
singletree[null_positions, parent.x, :, :]
문제가 해결 것으로 보인다. 이 작업은 추가 작업과 관련하여 어떤 차이가 있습니까?
입력 배열의 모양은 무엇입니까? –
다음과 같이 가정 할 수 있습니다. singletree는 L x M x C x (C + 1) 행렬이고, posteriors는 N x L x C x (C + 1)입니다. 그것이 치수에 의존하지 않기 때문에 내 업데이 트를 봐라 (나는 1 분 안에 올릴 것이다), 나는 믿는다. – diningphil