how to get closest candidate out of N

19 views
Skip to first unread message

Severin Bahman

unread,
Jun 22, 2016, 1:07:14 PM6/22/16
to torch7
My model is producing a vector (1D tensor) X and I would like to train my model such that X is closest to vector  (1D tensor) Y which is among a set of N candidate vectors Z (2D tensor).

Ideally I would get the cosine distance (or pairwise distance) for each vector in z using sth like nn.PairwiseDistance or nn.CosineDistance. The problem is that these functions only compare 1 vector to 1 other vector not 1 to many. What is the proper way to do this in torch?

Any help is greatly appreciated.

Severin Bahman

unread,
Jun 23, 2016, 5:06:42 AM6/23/16
to torch7
Solved, I was looking at some old version of the documentation. It is explained in the newer version.
http://nn.readthedocs.io/en/latest/table/index.html#nn.CosineDistance
Reply all
Reply to author
Forward
0 new messages