Theano

Intro

Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently.

Check gpu is working


Test script:
from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(0)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print f.maker.fgraph.toposort()
t0 = time.time()
for i in xrange(iters):
    r = f()
t1 = time.time()
print 'Looping %d times took' % iters, t1 - t0, 'seconds'
print 'Result is', r
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print 'Used the cpu'
else:
    print 'Used the gpu'

 Run with two configurations:

$ THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python check1.py
[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]
Looping 1000 times took 3.06635117531 seconds
Result is [ 1.23178029  1.61879337  1.52278066 ...,  2.20771813  2.29967761
  1.62323284]
Used the cpu

$ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python check1.py
Using gpu device 0: GeForce GTX 580
[GpuElemwise{exp,no_inplace}(<CudaNdarrayType(float32, vector)>), HostFromGpu(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.638810873032 seconds
Result is [ 1.23178029  1.61879349  1.52278066 ...,  2.20771813  2.29967761
  1.62323296]
Used the gpu




windows life

doskey /history > commands.log  - dump command line promt history to file
some_command > output_file.txt 2>&1 -  Redirect stdout and stderr to the same file [src]

linux life

top - see running processes
df - check free disk space
baobab - free disk space
screen  - multiple virtual consoles in one real [ref], need installation in ubuntu
mc - file manager

ccsm - disabling smooth fades and animations (speedup interface, especially useful in VirtualBox)
sudo apt-get install compizconfig-settings-manager, then ccsm 




lambda functions in matlab

I discovered it during Machine learnin courses on Coursera

To specify the actual function we are minimizing, we use a \short-hand"
for specifying functions with the @(t) ( costFunction(t, X, y) ) . This
creates a function, with argument t, which calls your costFunction. This
allows us to wrap the costFunction for use with fminunc.

@(t) ( costFunction(t, X, y) )   - that's awesome

crop included graphics in latex

\documentclass{article}

\usepackage{graphicx}

\begin{document}
% crop left
\includegraphics[trim={5cm 0 0 0},clip]{path-to-image}
% crop right
\includegraphics[trim={0 0 5cm 0},clip]{path-to-image}
\end{document}
Use the trim option, which takes four space separated values.
 trim={<left> <lower> <right> <upper>}
Source: http://tex.stackexchange.com/a/57420

multiple "windows" in one linux terminal

use "screen" utility

ctrl-a-p - switch
ctrl-a-c - new
ctrl-a-Q - remove freeze
ctrl-a-s - freeze
ctrl-a-S - split, but doesn;t work

Fixed "latex2png: error: eps2eps failed to translate .pdf to .eps" message in latex2rtf

OMG!! I finally fixed it.
Under Windows latex2rtf diisplayed following error:
latex2png: error: eps2eps failed to translate l2r_00123.pdf to l2r_00123.eps
for each image in my latex file.
That was very sad because this method is used to convert all equations, fugures and tables in word format.
The configurations seemed ok:
The problem was in eps2eps script in miktex. This script is magical. I haven't completely understood why it does nothing when called from latex2rtf. At the same time it runs successfuly when running standalone.
i wrote my new script pdf2eps_my.bat with the following contents:
"C:\Program Files (x86)\gs\gs9.05\bin\gswin32c.exe" -q -dNOCACHE -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile=%2 %1
and changed script 
"c:\Program Files (x86)\latex2rtf\latex2png" 
I changed 
PDF2EPS="eps2eps" 
with 
PDF2EPS="pdf2eps_my" 
it works because miktex/bin directory is in my PATH