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