Skip to content

Instantly share code, notes, and snippets.

@gaebor
gaebor / theano-demo.ipynb
Last active March 17, 2016 12:39
theano demo 1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gaebor
gaebor / digit.ipynb
Created March 17, 2016 12:40
mnist digit recognition demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gaebor
gaebor / theano_install.sh
Last active August 31, 2018 13:27
how to install libgpuarray and make theano to perform 64bit, double precision, float64 calculations on (cuda capable) GPU
# the followings are expected to be installed
#
# virtualenv, git
# OpenBlas: https://github.com/xianyi/OpenBLAS
# cuda: https://developer.nvidia.com/cuda-downloads
ARGV=("$@")
function check_command
{
@gaebor
gaebor / test_batched_dot.py
Last active February 16, 2018 10:05
this example shows that narrow matrix product or batched dot product is poorly parallelized
from __future__ import print_function
import numpy
import theano
import sys
import time
n = 100000
i = 10
j = 10
k = 10
@gaebor
gaebor / tensorflow_install.sh
Last active September 8, 2016 11:53
tensorflow install
# the script assumes OpenBlas and Cuda installation
# make sure to have these in PATH (maybe not all are necessary)
# /usr/local/bin
# /usr/bin
# /bin
# /usr/local/cuda/
# /usr/local/cuda/bin
virtualenv tensorflow
source tensorflow/bin/activate
@gaebor
gaebor / test_cnmem.sh
Last active September 18, 2017 15:36
Test the cnmem library preallocation, in order to prevent concurrent memory allocations on GPU. python2 only!
# presupposes that theano with gpu is already installed
FILENAME=theano_cnmem_text.log
export THEANO_FLAGS="gpuarray.preallocate=0.5,device=cuda,floatX=float32"
A_BIT=2
pip install -U nvidia-ml-py
# http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
RED='\033[0;31m'
NC='\033[0m' # No Color
@gaebor
gaebor / Hamiltonian.m
Last active October 11, 2018 11:54
Wolfram Mathematica package for deriving Lagrangian and Hamiltonian (classical mechanics)
(* ::Package:: *)
BeginPackage["Hamiltonian`"]
arg::usage = "Generates symbolic argument list of given length, optionally given symbol name.";
arg[n_, symbol_: q] :=
Table[Symbol[ToString[symbol] <> ToString[i]], {i, 1, n}]
KineticEnergy::usage = "Generates kinetic energy formula from parameterized coordinates.";
KineticEnergy[X_, M_, n_, qsym_: q, tsym_: t] :=
@gaebor
gaebor / Geodetics.m
Last active January 29, 2019 18:12
wolfram Mathematica package to calculate geodetics from Riemannian metric
BeginPackage["Geodetics`"]
ChristoffelSymbols::usage = "Calculates Christoffel symbols of the second kind.
Provide the Riemannian metric as a matrix vaued function and the number of parameters.";
ChristoffelSymbols[G_, n_] :=
Function[{Args(*=Table[Subscript[x, q], {q, n}]*)},
Module[{ginv=Inverse[G@Args]},
Table[
1/2 Sum[
ginv[[m, k]] (D[G[Args][[k, i]], Args[[j]]] +
@gaebor
gaebor / bayesian_model_comparison.py
Last active May 2, 2019 14:52
Performs Bayesian Model Comparison to find the right mixture of Gaussians
from __future__ import print_function
import numpy
import theano
import theano.tensor as T
from thextensions import *
from sklearn.utils.extmath import softmax
import matplotlib
matplotlib.use('Agg')