TIL
/
PyTorch cosine similarity
Search
Duplicate
🔥
PyTorch cosine similarity
pytorch.org
Quickstart
import
torch
.
nn
as
nn v1
=
torch
.
randn
(
100
,
128
)
v2
=
torch
.
randn
(
100
,
128
)
cos
=
nn
.
CosineSimilarity
(
dim
=
1
,
eps
=
1e-6
)
# dim = 어느 dimension으로 cosine similarity를 구할 지 정해줌.
out
=
cos
(
v1
,
v2
)
Python
복사