Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
shaybensasson / .gitmessage
Last active July 31, 2018 08:42
My git commit template message
~ 50-character subject line ~
~ 72-character wrapped longer description. ~
# Description of why, not how.
# Feel free to be detailed.
# nano: use `ctrl+c` to get line/character position
@shaybensasson
shaybensasson / install-gcc-4.9.4.sh
Created March 5, 2018 15:30
Install gcc-4.9.4.sh which is compatible with matlab 2017b, ubuntu 16 gcc is 5.4.0
#!/bin/bash
# this script installs GCC 4.9.4
# to use it navigate to your home directory and type:
# sh install-gcc-4.9.4.sh
# download and install gcc 4.9.4
wget https://ftp.gnu.org/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.gz
tar xzf gcc-4.9.4.tar.gz
cd gcc-4.9.4
@shaybensasson
shaybensasson / dl_libs_versions.py
Created January 30, 2018 13:07
Versions of deep learning libs python script
import numpy
print('numpy.__version__')
print(numpy.__version__)
import theano
print('theano.__version__')
print(theano.__version__)
import tensorflow
print('tensorflow.__version__')
print(tensorflow.__version__)
import keras
@shaybensasson
shaybensasson / ipython-notebook.conf
Last active August 9, 2017 13:16
Jupyter upstart service for ubuntu (put it in /etc/init)
description "Jupyter Upstart script"
start on filesystem or runlevel [2345]
stop on shutdown
script
export HOME="/home/shay" cd $HOME/
echo $$ > /var/run/jupyter_start.pid
#exec jupyter-notebook --config='$HOME/.jupyter/jupyter_notebook.config.py'
#exec ipython notebook
@shaybensasson
shaybensasson / mnist_nlp_seed.py
Last active June 14, 2017 08:47
trying keras to be random seeded (with theano and/or tf)
'''
trying keras to be random seeded
Switch backends by changin ~/.keras/keras.json:
Theano: https://drive.google.com/open?id=0B-FcStylmYuVU1E5S25QX2JXcGs
TensorFlow: https://drive.google.com/open?id=0B-FcStylmYuVNnpfZERoeUo0QnM
Keras Backend:
*Theano (1 epoch, GPU):
Test loss: 0.111780489241
@shaybensasson
shaybensasson / timing.py
Created June 14, 2017 07:54
timing in python
import time
from timeit import default_timer as timer
from datetime import timedelta
t_start = timer()
time.sleep(1)
#print(timer()-t_start)
print(timedelta(seconds=timer()-t_start))
@shaybensasson
shaybensasson / xor_donut_Shay.py
Created November 27, 2016 12:13
Pure Numpy implementation of Anns with 1 hidden layer solving Xor and Donut classification problems
# revisiting the XOR and donut problems to show how features
# can be learned automatically using neural networks.
#
# the notes for this class can be found at:
# https://www.udemy.com/data-science-deep-learning-in-python
import numpy as np
import matplotlib.pyplot as plt
# for binary classification! no softmax here
@shaybensasson
shaybensasson / autotime_magic.py
Last active September 10, 2019 19:33
autotime magic - Simple way to measure cell execution time in ipython notebook
#OBSOLETE:
#http://stackoverflow.com/questions/32565829/simple-way-to-measure-cell-execution-time-in-ipython-notebook
#%install_ext https://raw.github.com/cpcloud/ipython-autotime/master/autotime.py
#use: pip install ipython-autotime
%load_ext autotime
@shaybensasson
shaybensasson / theano_keras_gpu_config.py
Last active October 30, 2016 04:10
Configure GPU for deep learning libs
import os,random
os.environ["KERAS_BACKEND"] = "theano"
os.environ["THEANO_FLAGS"] = "device=gpu,lib.cnmem=0.6"
#os.environ["THEANO_FLAGS"] = "device=cpu"
!nvidia-smi
@shaybensasson
shaybensasson / translate.m
Created August 12, 2016 17:06
translates one range to another range
function [ret] = translate(value, leftMin, leftMax, rightMin, rightMax)
% Figure out how 'wide' each range is
leftSpan = leftMax - leftMin;
rightSpan = rightMax - rightMin;
% Convert the left range into a 0-1 range (float)
valueScaled = (value - leftMin) / (leftSpan);
% Convert the 0-1 range into a value in the right range.
ret = rightMin + (valueScaled * rightSpan);