Skip to content

Instantly share code, notes, and snippets.

@oak-tree
oak-tree / gist:49fcbee1d2ecfb11c78b1b64bafc9a76
Created March 31, 2017 11:50
mnist_with_digit_limit_parameter
'''Train a Siamese MLP on pairs of digits from the MNIST dataset.
It follows Hadsell-et-al.'06 [1] by computing the Euclidean distance on the
output of the shared network and by optimizing the contrastive loss (see paper
for mode details).
[1] "Dimensionality Reduction by Learning an Invariant Mapping"
http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
Gets to 99.5% test accuracy after 20 epochs.
from keras import backend as K
if K.backend() == "tensorflow":
print("Using tensorflow - try to use jit")
import keras.backend.tensorflow_backend as bck
config = bck.tf.ConfigProto()
config.graph_options.optimizer_options.global_jit_level = bck.tf.OptimizerOptions.ON_1
bck.set_session(bck.tf.Session(config=config))
1 #include <Python.h>
2 #include <iostream>
3 #include "theano_mod_helper.h"
4 #include "cuda_ndarray.cuh"
5 //////////////////////
6 //// Support Code
7 //////////////////////
8
9
10 namespace {
for i in \"*\";do echo "$i"; mv "$i" "$(echo "$i" | tr -d \")";done;
@oak-tree
oak-tree / Attachable.java
Last active November 20, 2016 16:47
spring upload file
public interface Attachable {
public File getFile();
public String getTitle();
public String getDescription();
public String getRealFileName();
public Double getSize();//double?
public void saveFile(File destination);
}
@oak-tree
oak-tree / nginx + php
Created June 23, 2016 09:53
nginx + php configration
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
#
# # With php5-cgi alone:
@oak-tree
oak-tree / commands.sh
Last active June 23, 2016 14:02
installing ngix + mysql on ec2 ubuntu
####READ COMMENTS
#### comments contain instruction that are must be done and not via terminal!
#############################################################################
# install ubuntu
# make sure to add security group that allows to connect mysql instance
sudo apt-get update
# add ngix repository
#ubnutu get stable
sudo -s
for (i=1;i<100;i++) {console.log(i + " " + Math.log2(i) + " " + Math.ceil(Math.log2(i)));}
@oak-tree
oak-tree / loadcsvlocal.sql
Created February 8, 2016 15:37
how to load csv file into mysql
LOAD DATA INFILE 'treksheb.csv' into table treks_heb
-> FIELDS TERMINATED BY ','
-> ENCLOSED BY '"'
-> LINES TERMINATED BY '\r\n'
-> IGNORE 1 LINES
-> (ProductId,name,Shortdescription,FullDescription,AttributeTypeId,CustomValue,DisplayOrder,SpecificationAttributeName,SpecificationAttributeOptionName);
@oak-tree
oak-tree / iframe.html
Last active January 25, 2016 12:08
Test environment for birds.co.il
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<style type="text/css">
html, body {
height: 100%;
margin: 0;
}
iframe {