theano

keras ignoring values in $HOME/.keras/keras.json file

帅比萌擦擦* 提交于 2019-12-04 02:54:48
I know the default backend for Keras has switched from Theano to TensorFlow, but with the dev version of Theano I can train on the GPU with OpenCL (I have an AMD card). However, when I import Keras, it only uses the TensorFlow backend even after I changed the values in the Keras configuration file : ~ $ cat $HOME/.keras/keras.json {"epsilon": 1e-07, "floatx": "float32", "backend": "theano"} ~ $ python -c 'import keras' Using TensorFlow backend. ~ $ KERAS_BACKEND=theano python -c 'import keras' Using Theano backend. Mapped name None to device opencl0:2: AMD Radeon R9 M370X Compute Engine In

Customize Keras' loss function in a way that the y_true will depend on y_pred

一世执手 提交于 2019-12-04 01:12:17
问题 I'm working on a multi-label classifier. I have many output labels [1, 0, 0, 1...] where 1 indicates that the input belongs to that label and 0 means otherwise. In my case the loss function that I use is based on MSE. I want to change the loss function in a way that when the output label is -1 than it will change to the predicted probability of this label. Check the attached images to best understand what I mean: The scenario is - when the output label is -1 I want the MSE to be equal to zero

Error importing theano “cannot import name gof”

不想你离开。 提交于 2019-12-04 00:38:15
问题 I am current getting the error ImportError: cannot import name gof when importing theano. >>> import theano Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> import theano File "C:\Python27\lib\site-packages\theano\__init__.py", line 63, in <module> from theano.compile import ( File "C:\Python27\lib\site-packages\theano\compile\__init__.py", line 9, in <module> from theano.compile.function_module import * File "C:\Python27\lib\site-packages\theano\compile\function

Theano CNN on CPU: AbstractConv2d Theano optimization failed

…衆ロ難τιáo~ 提交于 2019-12-04 00:03:45
I'm trying to train a CNN for object detection on images with the CIFAR10 dataset for a seminar at my university but I get the following Error: AssertionError: AbstractConv2d Theano optimization failed: there is no implementation available supporting the requested options. Did you exclude both "conv_dnn" and "conv_gemm" from the optimizer? If on GPU, is cuDNN available and does the GPU support it? If on CPU, do you have a BLAS library installed Theano can link against? I am running Anaconda 2.7 within a Jupyter notebook (CNN training on CPU) from a Windows 10 machine. As I already have updated

Python keras neural network (Theano) package returns an error about data dimensions

浪子不回头ぞ 提交于 2019-12-03 21:10:46
I have this code: import numpy as np from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation from keras.optimizers import SGD from sklearn import datasets import theano iris = datasets.load_iris() X = iris.data[:,0:3] # we only take the first two features. Y = iris.target X = X.astype(theano.config.floatX) Y = Y.astype(theano.config.floatX) model = Sequential() model.add(Dense(150, 1, init='uniform')) model.add(Activation('tanh')) model.add(Dropout(0.5)) model.add(Dense(150, 1, init='uniform')) model.add(Activation('tanh')) model.add(Dropout(0.5)) model.add

How to enable Keras with Theano to utilize multiple GPUs

三世轮回 提交于 2019-12-03 17:26:39
问题 Setup: Using a Amazon Linux system with a Nvidia GPU I'm using Keras 1.0.1 Running Theano v0.8.2 backend Using CUDA and CuDNN THEANO_FLAGS="device=gpu,floatX=float32,lib.cnmem=1" Everything works fine, but I run out of video memory on large models when I increase the batch size to speed up training. I figure moving to a 4 GPU system would in theory either improve total memory available or allow smaller batches to build faster, but observing the the nvidia stats, I can see only one GPU is used

How to find wrong prediction cases in test set (CNNs using Keras)

寵の児 提交于 2019-12-03 17:17:58
问题 I'm using MNIST example with 60000 training image and 10000 testing image. How do I find which of the 10000 testing image that has an incorrect classification/prediction? 回答1: Simply use model.predict_classes() and compare the output with true labes. i.e: incorrects = np.nonzero(model.predict_class(X_test).reshape((-1,)) != y_test) to get indices of incorrect predictions 来源: https://stackoverflow.com/questions/39300880/how-to-find-wrong-prediction-cases-in-test-set-cnns-using-keras

How Adagrad wroks in Keras? What does self.weights mean in Keras Optimizer?

馋奶兔 提交于 2019-12-03 16:44:42
For example, the implementation of Keras' Adagrad has been: class Adagrad(Optimizer): """Adagrad optimizer. It is recommended to leave the parameters of this optimizer at their default values. # Arguments lr: float >= 0. Learning rate. epsilon: float >= 0. decay: float >= 0. Learning rate decay over each update. # References - [Adaptive Subgradient Methods for Online Learning and Stochastic Optimization](http://www.jmlr.org/papers/volume12/duchi11a/duchi11a.pdf) """ def __init__(self, lr=0.01, epsilon=1e-8, decay=0., **kwargs): super(Adagrad, self).__init__(**kwargs) self.lr = K.variable(lr)

Correctly loading Keras model in Django that supports multi-tenancy

扶醉桌前 提交于 2019-12-03 15:23:18
I am try to write a REST api in django that uses a Keras model to return a prediction. However the load_model() function takes some time to load the model and I don't want my users to have to wait so long (each time the model is initialized). What would be the correct way to initialize the model so that is is loaded once and the predictions are done using that same model? On a side note one method that I thought cold be possible was to initialize the model in settings.py as below : settings.py json_file=open("model.json","r") loaded_json=json_file.read() json_file.close() model=model_from_json

Keras: reshape to connect lstm and conv

北城余情 提交于 2019-12-03 13:13:56
问题 This question exists as a github issue , too. I would like to build a neural network in Keras which contains both 2D convolutions and an LSTM layer. The network should classify MNIST. The training data in MNIST are 60000 grey-scale images of handwritten digits from 0 to 9. Each image is 28x28 pixels. I've splitted the images into four parts (left/right, up/down) and rearranged them in four orders to get sequences for the LSTM. | | |1 | 2| |image| -> ------- -> 4 sequences: |1|2|3|4|, |4|3|2|1