tikz cookbook


Drawing on an image with TikZ
http://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz

Drawing label on figure (using tikz)
\begin{tikzpicture}
            \node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[trim={600px 200px 50px 200px},clip, width=1\linewidth]{images/DP_10150_simpleCombinedBasedOnDPlen.exe_scale1_blank/frm00001}};
            %\draw[white,fill=white] (0.0,0.0) rectangle (0.5,0.5);
            \node[minimum size=.6cm, fill=white,anchor=south west] at (0.0,0.0){а};        \end{tikzpicture}

displaying multiple grayscale figures in python's matplotlib

from matplotlib import pyplot as plt
import matplotlib.cm as cm
plt.figure()  # without this it display one after another
plt.imshow(image_one, cmap=cm.gray) # without cm.gray it displays grayscale images in colormap
plt.imshow(image_two, cmap=cm.gray) #
plt.show()

use
%matplotlib inline
in ipython notebook to display image inplace


Shorter version:
%matplotlib inline
import matplotlib.pyplot as plt
plt.axis('off')
plt.imshow(dpt, cmap=plt.cm.gray, interpolation='nearest')

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