ipython. save notebook as script

Joint solution from http://stackoverflow.com/a/23619544 and http://stackoverflow.com/a/19067979

# [1]
%%javascript
var kernel = IPython.notebook.kernel;
var thename = window.document.getElementById("notebook_name").innerHTML;
var command = "theNotebook = " + "'"+thename+"'";
kernel.execute(command);

# [2]
try :
    if(__IPYTHON__) :
        get_ipython().system(u'ipython nbconvert --to python {}.ipynb'.format(theNotebook))
except NameError :
    pass

Use Matlab function from python

There are several solutions:
Source: http://stackoverflow.com/questions/2883189/calling-matlab-functions-from-python

pymat

A low level interface to Matlab using the matlab engine (libeng) for communication (basically a library that comes with matlab). The module has to be compiled and linked with libeng.
http://pymat.sourceforge.net
Last updated: 2003

pymat2

A somewhat short lived continuation of the pymat development. Seems to work on windows (including 64bit), linux and mac (with some changes).
https://code.google.com/p/pymat2/
Last updated: 2012

mlabwrap

A high level interface that also comes as a module which needs compilation and linking against libeng. It exposes Matlab functions to python so you can do fun stuff like
mlab.plot(x, y, 'o')
http://mlabwrap.sourceforge.net
Last updated: 2009

mlab

A repackaging effort of mlabwrap. Basically it replaces the c++ code that links against 'libeng' in mlabwrap with a python module (matlabpipe) that communicates with matlab through a pipe. The main advantage of this is that it doesn't need compilation of any kind.
Unfortunately the package currently has a couple of bugs and doesn't seem to work on the mac at all. I reported a few of them but gave up eventually. Also, be prepared for lots of trickery and a bunch of pretty ugly hacks if you have to go into the source code ;-) If this becomes more mature it could be one of the best options.
https://github.com/ewiger/mlab
last update: 2013

pymatlab

A newer package (2010) that also interacts with Matlab through libeng. Unlike the other packages this one loads the engine library through ctypes thus no compilation required. Its not without flaws but still being maintained and the (64bit Mac specific) issues I found should be easy enough to fix.
(edit 2014-05-20: it seems those issues have already been fixed in the source so things should be fine with 0.2.4)
http://pymatlab.sourceforge.net
last update: 2014

python-matlab-bridge

Also a newer package that is still actively maintained. Communicates with Matlab through some sort of socket. Unfortunately the exposed functions are a bit limited. I couldn't figure out how to invoke a function that takes structs as parameters. Requires zmq, pyzmq and IPython which are easy enough to install.
http://arokem.github.io/python-matlab-bridge
last update: 2014


Bug report for Mlab:

http://stackoverflow.com/questions/20659616/python-mlab-cannot-import-name-find-available-releases
Fixed here:
https://github.com/ewiger/mlab/commit/4bfa59af2a1a996a774c80d7aafc4a390f548669
 

Pylearn2 out of memory error

I am trying to train NN using pylearn2
I use stochastic gradient decent.
I had always a message about failed GPU memory  allocation in
train->self.sgd_update(*batch)
To fix it, I reduced size of the batch in yaml-config:
batch_size: 200
was replaced by
batch_size: 100