Skip to content

Instantly share code, notes, and snippets.

View zygmuntz's full-sized avatar

Zygmunt Zając zygmuntz

View GitHub Profile
@zygmuntz
zygmuntz / mnist_siamese_graph_mod.py
Last active May 1, 2020 19:20
A Siamese network example modified to use weighted L1 distance and cross-entropy loss.
#!/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
"""
@zygmuntz
zygmuntz / one_hot.m
Created October 11, 2013 18:31
One way of doing one-hot encoding in Matlab
% 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