comparing between two tensors

Jude's Sound Lab·2023년 1월 22일
0

Note for 2023

목록 보기
1/10

When comparing two tensors, the == operator compares the values of each element in the tensors, and if there is even one element that is not equal, it will return False.

exmaple)

cos_sim_value_1 == cos_sim_value_2 # not enough for comparison between two tensors
torch.allclose(cos_sim_value_1[0], cos_sim_value_2[0], atol=1e-5) # True, matrix multiplication causal

cos_sim_value_1[0][0], cos_sim_value_2[0][0]
# (tensor(0.8399), tensor(0.8399))
cos_sim_value_1[0][0].item(), cos_sim_value_2[0][0].item()
# (0.839893102645874, 0.8398933410644531)
profile
chords & code // harmony with structure

0개의 댓글

관련 채용 정보