theano

Convert Keras model to C++ [closed]

一个人想着一个人 提交于 2019-11-27 06:44:25
I am using Keras (with Theano) to train my CNN model. Does anyone has idea how can I use it in my C++ application? Does anyone tried something similar? I have idea to write some python code that will generate a c++ code with network functions - any suggestion on it? I found a similar question here how to use Tensorflow Keras model in C++ but without answer. To answer my own question and have a solution - I wrote a plain c++ solution called keras2cpp (its code available on github). In this solution you store network architecture (in json) and weights (in hdf5). Then you can dump a network to a

theano - use tensordot compute dot product of two tensor

佐手、 提交于 2019-11-27 06:21:39
问题 I want to use tensordot to compute the dot product of a specific dim of two tensors. Like: A is a tensor, whose shape is (3, 4, 5) B is a tensor, whose shape is (3, 5) I want to do a dot use A's third dim and B's second dim, and get a output whose dims is (3, 4) Like below: for i in range(3): C[i] = dot(A[i], B[i]) How to do it by tensordot? 回答1: Well, do you want this in numpy or in Theano? In the case, where, as you state, you would like to contract axis 3 of A against axis 2 of B, both are

Installing theano

拈花ヽ惹草 提交于 2019-11-27 04:51:53
问题 I installed theano with Spyder 2.3.8 on Windows 7 64-bit by running "pip install theano". It worked well. But then, when I tried to run "import theano", I got the following error: Traceback (most recent call last): File "", line 1, in import theano File "D:\Anaconda3\lib\site-packages\theano\__init__.py", line 55, in from theano.compile import \ File "D:\Anaconda3\lib\site-packages\theano\compile\__init__.py", line 9, in from theano.compile.function_module import * File "D:\Anaconda3\lib\site

Deep-Learning Nan loss reasons

这一生的挚爱 提交于 2019-11-27 04:11:24
问题 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: tf.contrib.learn.DNNClassifier(feature_columns=feature_columns, hidden_units=[300, 300,

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

别来无恙 提交于 2019-11-27 03:21:25
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 of neural networks (using Keras) ) get_output = theano.function([model.layers[0].input],model.layers[-1].output,allow_input_downcast=True) fx = theano.function([model.layers[0].input] ,T.jacobian(model.layers[-1].output.flatten(),model.layers[0].input), allow_input_downcast=True) grad = fx([trainingData]) Any ideas on

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

≯℡__Kan透↙ 提交于 2019-11-27 03:13:06
问题 running a Dense feed-forward neural net in Keras. there are class_weights for two outputs, and sample_weights for a third output. fore some reason it prints the progress verbose display for each batch calculated, and not updating the print on the same line as its supposed to... Did this ever happens to you? How is it fixed? From the shell: 42336/747322 [====>.........................] - ETA: 79s - loss: 20.7154 - x1_loss: 9.5913 - x2_loss: 10.0536 - x3_loss: 1.0705 - x1_acc: 0.6930 - x2_acc:

How to compute Receiving Operating Characteristic (ROC) and AUC in keras?

浪尽此生 提交于 2019-11-27 02:42:54
I have a multi output(200) binary classification model which I wrote in keras. In this model I want to add additional metrics such as ROC and AUC but to my knowledge keras dosen't have in-built ROC and AUC metric functions. I tried to import ROC, AUC functions from scikit-learn from sklearn.metrics import roc_curve, auc from keras.models import Sequential from keras.layers import Dense . . . model.add(Dense(200, activation='relu')) model.add(Dense(300, activation='relu')) model.add(Dense(400, activation='relu')) model.add(Dense(300, activation='relu')) model.add(Dense(200,init='normal',

How to switch Backend with Keras (from TensorFlow to Theano)

旧时模样 提交于 2019-11-27 00:26:35
问题 I tried to switch Backend with Keras (from TensorFlow to Theano) but did not manage. I followed the temps described here but it doesn't work. I created a keras.json in the keras' directory (as it did not exist) but it doesn't change anything when I import it from Python. 回答1: Create a .keras (note the . in front) folder in you home directory and put the keras.json file there. For example, /home/DaniPaniz/.keras/keras.json (or ~/.keras/keras.json in short) if you are on a UNIX like system

How do I install theano in Anaconda ver. 2.1 Windows 64 bit for Python 3.4?

亡梦爱人 提交于 2019-11-26 23:16:16
I've installed Anaconda . Now I want to install the Theano library in Anaconda. I have tried: The Theano installer for Anaconda from http://deeplearning.net/software/theano/install.html#windows-installer-for-anacondace , but it raises error "The installer could not find a version of Anaconda installed. Please download and install Anaconda CE". I have added ~/anaconda3, ~/anaconda3/scripts to the environment variable path. I have tried to install it by building the package as mentioned on Stack Overflow, How do I keep track of pip-installed packages in an Anaconda (Conda) environment? , but

How to install Theano on Anaconda Python 2.7 x64 on Windows?

泄露秘密 提交于 2019-11-26 22:45:33
问题 I wonder how to install Theano on Anaconda Python 2.7 x64 on Windows 7 x64. The Theano website provides some instructions but is not clear as to what is specific to Anaconda. 回答1: I'm not 100% certain but this may be a minimal set of instructions, but only if you don't want to use a GPU. Getting Theano to use a GPU on Windows is quite a bit more difficult. Install TDM GCC x64. Install Anaconda x64. run conda update conda . run conda update --all . run conda install mingw libpython . Install