This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
A Siamese network example modified to use weighted L1 distance and cross-entropy loss, as in | |
Siamese Neural Networks for One-shot Image Recognition | |
http://www.cs.toronto.edu/~rsalakhu/papers/oneshot1.pdf | |
""" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% y is a vector of labels | |
y_one_hot = zeros( size( y, 1 ), n_classes ); | |
% assuming class labels start from one | |
for i = 1:n_classes | |
rows = y == i; | |
y_one_hot( rows, i ) = 1; | |
end |