Use of None in Array indexing in Python

This question has been asked and answered on the Theano mailing list, but is actually about the basics of numpy indexing. Here are the question and answer https://groups.google.com/forum/#!topic/theano-users/jq92vNtkYUI For completeness, here is another explanation: slicing with None adds an axis to your array, see the relevant numpy documentation, because it behaves the same in both … Read more

Keras verbose training progress bar writing a new line on each batch issue

I’ve added built-in support for keras in tqdm so you could use it instead (pip install “tqdm>=4.41.0”): from tqdm.keras import TqdmCallback … model.fit(…, verbose=0, callbacks=[TqdmCallback(verbose=2)]) This turns off keras‘ progress (verbose=0), and uses tqdm instead. For the callback, verbose=2 means separate progressbars for epochs and batches. 1 means clear batch bars when done. 0 means … Read more

How to change Keras backend (where’s the json file)?

After looking at keras sources (this place): Start up your python-binary and do the following import os print(os.path.expanduser(‘~’)) # >>> C:\\Users\\Sascha’ # will look different for different OS This should be the base-directory Keras will build an folder .keras there where keras.json resides (if it was already created). If it’s not there, create it there … Read more

Unsupervised pre-training for convolutional neural network in theano

This paper describes an approach for building a stacked convolutional autoencoder. Based on that paper and some Google searches I was able to implement the described network. Basically, everything you need is described in the Theano convolutional network and denoising autoencoder tutorials with one crucial exception: how to reverse the max-pooling step in the convolutional … Read more

How to set up theano config

Theano does not create any configuration file by itself, but has default values for all its configuration flags. You only need such a file if you want to modify the default values. This can be done by creating a .theanorc file in your home directory. For example, if you want floatX to be always float32, … Read more

Keras uses way too much GPU memory when calling train_on_batch, fit, etc

It is a very common mistake to forget that the activations, gradients and optimizer moment tracking variables also take VRRAM, not just the parameters, increasing memory usage quite a bit. The backprob calculations themselves make it so the training phase takes almost double the VRAM of forward / inference use of the neural net, and … Read more

Activation function after pooling layer or convolutional layer?

Well, max-pooling and monotonely increasing non-linearities commute. This means that MaxPool(Relu(x)) = Relu(MaxPool(x)) for any input. So the result is the same in that case. So it is technically better to first subsample through max-pooling and then apply the non-linearity (if it is costly, such as the sigmoid). In practice it is often done the … Read more

How to plot a chart in the terminal

termplotlib (a small project of mine) might come in handy here. Install with pip install termplotlib and produce terminal plots like import termplotlib as tpl import numpy as np x = np.linspace(0, 2*np.pi, 100) y = np.sin(x) + x fig = tpl.figure() fig.plot(x, y, width=60, height=20) fig.show() 7 +—————————————————+ | | 6 | ** | … Read more