theano

How to save / serialize a trained model in theano?

霸气de小男生 提交于 2020-01-01 09:13:02
问题 I saved the model as documented on loading and saving. # saving trained model f = file('models/simple_model.save', 'wb') cPickle.dump(ca, f, protocol=cPickle.HIGHEST_PROTOCOL) f.close() ca is a trained auto-encoder. It's a instance of class cA. From the script in which I build and save the model I can call ca.get_reconstructed_input(...) and ca.get_hidden_values(...) without any problem. In a different script I try to load the trained model. # loading the trained model model_file = file(

How to save / serialize a trained model in theano?

心不动则不痛 提交于 2020-01-01 09:12:31
问题 I saved the model as documented on loading and saving. # saving trained model f = file('models/simple_model.save', 'wb') cPickle.dump(ca, f, protocol=cPickle.HIGHEST_PROTOCOL) f.close() ca is a trained auto-encoder. It's a instance of class cA. From the script in which I build and save the model I can call ca.get_reconstructed_input(...) and ca.get_hidden_values(...) without any problem. In a different script I try to load the trained model. # loading the trained model model_file = file(

Theano: Initialisation of device gpu failed! Reason=CNMEM_STATUS_OUT_OF_MEMORY

流过昼夜 提交于 2020-01-01 08:49:31
问题 I am running the example kaggle_otto_nn.py of Keras with backend of theano . When I set cnmem=1 , the following error comes out: cliu@cliu-ubuntu:keras-examples$ THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32,lib.cnmem=1 python kaggle_otto_nn.py Using Theano backend. ERROR (theano.sandbox.cuda): ERROR: Not using GPU. Initialisation of device gpu failed: initCnmem: cnmemInit call failed! Reason=CNMEM_STATUS_OUT_OF_MEMORY. numdev=1 /usr/local/lib/python2.7/dist-packages/Theano-0.8.0rc1

How can I speed up deep learning on a non-NVIDIA setup?

余生长醉 提交于 2020-01-01 02:51:46
问题 Since I only have an AMD A10-7850 APU, and do not have the funds to spend on a $800-$1200 NVIDIA graphics card, I am trying to make due with the resources I have in order to speed up deep learning via tensorflow/keras. Initially, I used a pre-compiled version of Tensorflow. InceptionV3 would take about 1000-1200 seconds to compute 1 epoch. It has been painfully slow. To speed up calculations, I first self-compiled Tensorflow with optimizers (using AVX, and SSE4 instructions). This lead to a

How to get value from a theano tensor variable backed by a shared variable?

坚强是说给别人听的谎言 提交于 2020-01-01 02:33:05
问题 I have a theano tensor variable created from casting a shared variable. How can I extract the original or casted values? (I need that so I don't have to carry the original shared/numpy values around.) >>> x = theano.shared(numpy.asarray([1, 2, 3], dtype='float')) >>> y = theano.tensor.cast(x, 'int32') >>> y.get_value(borrow=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'TensorVariable' object has no attribute 'get_value' # whereas I can do this

What is data type for Python Keras deep learning package?

◇◆丶佛笑我妖孽 提交于 2019-12-31 23:03:32
问题 I didn't find anything about data type that we need to work with Python Keras deep learning package with this link. I checked array and list but returned error. Any clue? 回答1: Keras uses numpy arrays containing the theano.config.floatX floating point type. This can be configured in your .theanorc file. Typically, it will be float64 for CPU computations and float32 for GPU computations, although you can also set it to float32 when working on the CPU if you prefer. You can create a zero-filled

How to put my dataset in a .pkl file in the exact format and data structure used in “mnist.pkl.gz”?

你说的曾经没有我的故事 提交于 2019-12-31 10:45:53
问题 I'm trying to use the Theano library in python to do some experiments with Deep Belief Networks. I use the code in this address: DBN full code. This code use the MNIST Handwritten database. This file is already in pickle format. It is unpicked in: train_set valid_set test_set Which is further unpickled in: train_set_x, train_set_y = train_set valid_set_x, valid_set_y = valid_set test_set_x, test_set_y = test_set Please can someone give me the code that constructs this dataset in order to

Unable to create lambda function in hierarchical pymc3 model

北城以北 提交于 2019-12-31 04:17:42
问题 I'm trying to create the model shown below with PyMC 3 but can't figure out how to properly map probabilities to the observed data with a lambda function. import numpy as np import pymc as pm data = np.array([[0, 0, 1, 1, 2], [0, 1, 2, 2, 2], [2, 2, 1, 1, 0], [1, 1, 2, 0, 1]]) (D, W) = data.shape V = len(set(data.ravel())) T = 3 a = np.ones(T) b = np.ones(V) with pm.Model() as model: theta = [pm.Dirichlet('theta_%s' % i, a, shape=T) for i in range(D)] z = [pm.Categorical('z_%i' % i, theta[i],

How to turn entire keras model into theano function

六月ゝ 毕业季﹏ 提交于 2019-12-30 06:41:08
问题 I want to turn my keras model into a theano function so that I can compute the gradients on the inputs. I thought this might be cool for visualizing the network. I want to use these gradients to enhance features in the original image based on what the neural network thinks they are. I do not understand what I am doing wrong with the following code. model = Sequential() model.add(InputLayer((3, H, W))) model.add(GaussianNoise(0.03)) model.add(Flatten()) model.add(Dense(512, activation = 'relu'

Python/Keras/Theano wrong dimensions for Deep Autoencoder

有些话、适合烂在心里 提交于 2019-12-30 04:25:10
问题 I'm trying to follow the Deep Autoencoder Keras example. I'm getting a dimension mismatch exception, but for the life of me, I can't figure out why. It works when I use only one encoded dimension, but not when I stack them. Exception: Input 0 is incompatible with layer dense_18: expected shape=(None, 128), found shape=(None, 32)* The error is on the line decoder = Model(input=encoded_input, output=decoder_layer(encoded_input)) from keras.layers import Dense,Input from keras.models import