theano

Error while calling eval() on Tensor variable in keras

*爱你&永不变心* 提交于 2019-12-08 09:33:21
问题 I am using keras and using a layer output for some modifications. Before, using the output ( a tensor variable ) I am converting it to numpy array and thus calling eval() on it, as below: def convert_output(orig_output): conv_output = invoke_modifications(orig_output.eval(), 8) The code fails with following error: File "<ipython-input-11-df86946997d5>", line 1, in <module> orig_output.eval() File "C:\ENV\p34\lib\site-packages\theano-0.9.0.dev4-py3.4.egg\theano\gof\graph.py", line 516, in eval

compilation issue when running theano

≯℡__Kan透↙ 提交于 2019-12-08 08:04:05
问题 I installed theano on windows 8, 64 bit. I am using anaconda implementation, python 3.4. Trying to install theano, I diligently followed all steps on this link (which helped on another computer with similar configuration): http://rosinality.ncity.net/doku.php?id=python:installing_theano (English and Korean) whenever I type 'import theano' on my IDE (pycharm) I get a long error message, but I believe the most meaningful portion is: import theano >>>>Exception: Compilation failed (return status

Changing pretrained AlexNet classification in Keras

我只是一个虾纸丫 提交于 2019-12-08 05:31:49
问题 I am using a AlexNet with pretrained weights(heuritech/convnets-keras) for a classification problem with 8 classes instead of 1000. After initialising the network with Model(input=..,output=..) and loading the initial weights, I drop the last two layers, Dense(1000) and Activation(softmax), and add my own two layers: Dense(8) and Activation(softmax). But then, after running I get an error Error when checking model target: expected softmax to have shape (None, 1000) but got array with shape

Theano with Anaconda on Windows: how to setup BLAS?

我怕爱的太早我们不能终老 提交于 2019-12-08 05:19:29
I've used Anaconda to install Theano (and Keras) on Windows 7 64bit. Here are my steps. Install the latest Anaconda for Python 3.5 conda install mingw libpython pip install Theano conda install pydot-ng pip install keras Edit .keras/keras.json to use "theano" instead of "tensorflow". Open Jupyter, copy and paste this code: https://github.com/fchollet/keras/blob/master/examples/cifar10_cnn.py It executes fine until the call to model.fit : imports, data download, model compilation all work. Please note that I set data_augmentation to False. The call to model.fit fails with the following error

Why does the floatX's flag impact whether GPU is used in Theano?

三世轮回 提交于 2019-12-08 02:30:12
问题 I am testing Theano with GPU using the script provided in the tutorial for that purpose: # Start gpu_test.py # From http://deeplearning.net/software/theano/tutorial/using_gpu.html#using-gpu from theano import function, config, shared, sandbox import theano.tensor as T import numpy import time vlen = 10 * 30 * 768 # 10 x #cores x # threads per core iters = 1000 rng = numpy.random.RandomState(22) x = shared(numpy.asarray(rng.rand(vlen), config.floatX)) f = function([], T.exp(x)) print(f.maker

Update keras.json on Google Colab

送分小仙女□ 提交于 2019-12-08 02:11:59
问题 I tried to update keras.json on Google Colabs, but its throwing UnsupportedOperation error Is there any other alternative to achieve this? 回答1: You're opening the file as readonly -- pass 'w' to the open call on line 9. (docs) 来源: https://stackoverflow.com/questions/50083075/update-keras-json-on-google-colab

Indexing tensor with index matrix in theano?

孤街浪徒 提交于 2019-12-08 00:44:41
问题 I have a theano tensor A such that A.shape = (40, 20, 5) and a theano matrix B such that B.shape = (40, 20). Is there a one-line operation I can perform to get a matrix C, where C.shape = (40, 20) and C(i,j) = A[i, j, B[i,j]] with theano syntax? Essentially, I want to use B as an indexing matrix; what is the most efficient/elegant to do this using theano? 回答1: You can do the following in numpy: import numpy as np A = np.arange(4 * 2 * 5).reshape(4, 2, 5) B = np.arange(4 * 2).reshape(4, 2) % 5

How do you free up gpu memory?

99封情书 提交于 2019-12-07 16:21:17
问题 When running theano, I get an error: not enough memory. See below. What are some possible actions that can be taken to free up memory? I know I can close applications etc, but I just want see if anyone has other ideas. For example, is it possible to reserve memory? THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python conv_exp.py Using gpu device 0: GeForce GT 650M Trying to run under a GPU. If this is not desired, then modify network3.py to set the GPU flag to False. Error allocating

Python Numpy Error: ValueError: setting an array element with a sequence

人走茶凉 提交于 2019-12-07 15:11:14
问题 I am trying to build a dataset similar to mnist.pkl.gz provided in theano logistic_sgd.py implementation. Following is my code snippet. import numpy as np import csv from PIL import Image import gzip, cPickle import theano from theano import tensor as T def load_dir_data(csv_file=""): print(" reading: %s" %csv_file) dataset=[] labels=[] cr=csv.reader(open(csv_file,"rb")) for row in cr: print row[0], row[1] try: image=Image.open(row[0]+'.jpg').convert('LA') pixels=[f[0] for f in list(image

Advanced 2d indexing in Theano to extract multiple pixels from an image

你说的曾经没有我的故事 提交于 2019-12-07 09:59:50
问题 Background I have an image that I want to sample at a number (P) of x,y coordinates. In Numpy I can use advanced indexing to do this via: n_points = n_image[ [n_pos[:,1],n_pos[:,0]] ] This returns a vector of P pixels sampled from the image. Question How can I do this advanced indexing in Theano? What I've tried I've tried the corresponding code in theano: t_points = t_image[ [t_pos[:,1],t_pos[:,0]] ] this compiles and executes without any warning messages, but results in an output tensor of