theano

ValueError «You are trying to use the old GPU back-end» when importing keras

ValueError «You are trying to use the old GPU back-end» when importing keras Question: I’m using Keras with the Theano backend on Ubuntu 16.04. My setup has been working without issues, however, all of a sudden I get the following error when I import Keras (import keras): ValueError: You are trying to use the old …

Total answers: 3

Keras: How to get layer shapes in a Sequential model

Keras: How to get layer shapes in a Sequential model Question: I would like to access the layer size of all the layers in a Sequential Keras model. My code: model = Sequential() model.add(Conv2D(filters=32, kernel_size=(3,3), input_shape=(64,64,3) )) model.add(MaxPooling2D(pool_size=(3,3), strides=(2,2))) Then I would like some code like the following to work for layer in model.layers: print(layer.get_shape()) …

Total answers: 3

How to add and remove new layers in keras after loading weights?

How to add and remove new layers in keras after loading weights? Question: I am trying to do a transfer learning; for that purpose I want to remove the last two layers of the neural network and add another two layers. This is an example code which also output the same error. from keras.models import …

Total answers: 4

Theano with Keras on Raspberry Pi

Theano with Keras on Raspberry Pi Question: I am trying to get Theano to run with Keras on a Raspberry Pi 3 (B) without success. I tried Ubuntu MATE and Raspbian as operating systems, without success. To install Theano and Keras, I have taken following steps: Install miniconda (armv7 distribution) Install all Theano dependencies (as …

Total answers: 3

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

How to change Keras backend (where's the json file)? Question: I have installed Keras, and wanted to switch the backend to Theano. I checked out this post, but still have no idea where to put the created json file. Also, below is the error I got when running import keras in Python Shell: Using TensorFlow …

Total answers: 12

Deep-Learning Nan loss reasons

Deep-Learning Nan loss reasons Question: Perhaps too general a question, but can anyone explain what would cause a Convolutional Neural Network to diverge? Specifics: I am using Tensorflow’s iris_training model with some of my own data and keep getting ERROR:tensorflow:Model diverged with loss = NaN. Traceback… tensorflow.contrib.learn.python.learn.monitors.NanLossDuringTrainingError: NaN loss during training. Traceback originated with line: …

Total answers: 13

Getting gradient of model output w.r.t weights using Keras

Getting gradient of model output w.r.t weights using Keras Question: I am interested in building reinforcement learning models with the simplicity of the Keras API. Unfortunately, I am unable to extract the gradient of the output (not error) with respect to the weights. I found the following code that performs a similar function (Saliency maps …

Total answers: 2

How to plot a chart in the terminal

How to plot a chart in the terminal Question: I’m researching ML/Theano, and recently came across this script: https://gist.github.com/notmatthancock/68d52af2e8cde7fbff1c9225b2790a7f which was cool to play with. And like all ML researchers, I recently upgraded to a server, and while it’s more powerful, it also presented me with a problem. The script is very long, but it …

Total answers: 8

NaN loss when training regression network

NaN loss when training regression network Question: I have a data matrix in “one-hot encoding” (all ones and zeros) with 260,000 rows and 35 columns. I am using Keras to train a simple neural network to predict a continuous variable. The code to make the network is the following: model = Sequential() model.add(Dense(1024, input_shape=(n_train,))) model.add(Activation(‘relu’)) …

Total answers: 27