theano

theano: summation by class label

你离开我真会死。 提交于 2019-12-13 06:13:13
问题 I have a matrix which represents a distances to the k-nearest neighbour of a set of points, and there is a matrix of class labels of the nearest neighbours. (both N-by-k matrix) What is the best way in theano to build a (N-by-#classes) matrix whose (i,j) element will be the sum of distances from i-th point to its k-NN points with the class label 'j'? Example: # N = 2 # k = 5 # number of classes = 3 K_val = [[1,2,3,4,6], [2,4,5,5,7]] l_val = [[0,1,2,0,1], [2,0,1,2,0]] result = [[5,8,3], [11,5

How to install theano library on OS X?

天大地大妈咪最大 提交于 2019-12-13 03:56:53
问题 In my machine learning course we are going to start using theano, a very well known library for deep learning architectures. I all ready installed it with the following command: $ pip install Theano By the way, when i want to test if it installed correctly, the python interpreter can´t fin the module. I dont know if im installing it right. Reading the documentation i found anaconda, is it right to first install anaconda and then try to install again with pip theano?. Is this the right way to

Why can't I evaluate the reshaped tensorvariable in theano?

二次信任 提交于 2019-12-13 02:59:29
问题 Why can't I evaluate the reshaped tensorvariable through the code I wrote below? from theano import shared from theano import tensor as T import numpy x = T.matrix('x') # the input data # input = (nImages, nChannel(nFeatureMaps), nDim1, nDim2, nDim3) layer1_input = T.reshape(x, xTrain.shape, ndim=5) layer1_input.eval({x:xTrain}) Since I have reshape the tensorvariable x, and pass a numpy array of same dimension to it, it simply reports, TypeError: ('Bad input argument to theano function with

How to solve theano Segmentation fault?

本秂侑毒 提交于 2019-12-13 02:36:27
问题 I am running a python file which content is: import theano.tensor as T This gives me a Segmentation fault. I am using anaconda. How can this be solved? 回答1: I had the same problem after I updated scipy from version 0.17.1 to version 0.18.0 Try to create a virtual environment with conda (from Anaconda) only for theano, with the correct versions of scipy and numpy: conda create --name theano_env theano python=2.7 or (for python 3.5): conda create --name theano_env theano python=3.5 It solved

How to use theano.gradient.hessian? Example needed

核能气质少年 提交于 2019-12-13 02:04:49
问题 I tried the code below: x=T.dvector('x') y=T.dvector('y') input=[x,y] s=T.sum(x**2+y**2) f=theano.gradient.hessian(s,wrt=input) h=function(input,f) Then I run it with following real values x=[1,2] y=[1,2] h([x,y] Then I encountered following error TypeError: ('Bad input argument to theano function with name "<ipython-input-115-32fd257c46ad>:7" at index 0(0-based)', 'Wrong number of dimensions: expected 1, got 2 with shape (2L, 2L).') I am new to python and am exploring Theano for building

Theano: MissingInputError

风格不统一 提交于 2019-12-13 00:16:20
问题 this is a semplification of the original code that i'm trying to fix. I have invented a problem that reflects what the original code does and which gives me the same error but is written in a minimal form: import theano import theano.tensor as T import numpy as np import copy theano.config.exception_verbosity = 'high' class Test(object): def __init__(self): self.rate=0.01 def start(self, x, y): W_val=40.89 W=theano.shared(value=W_val, borrow=True) z=T.mean(x*W/y) gz=T.grad(z, W) updates=[(W,

Differences between index-assignment in Numpy and Theano's set_subtensor()

邮差的信 提交于 2019-12-12 21:06:49
问题 I am trying to do index-assignment in Theano using set_subtensor(), but it is giving different results to Numpy's index-assignment. Am I doing something wrong, or is this a difference in how set_subtensor and Numpy's index-assignment work? What I want to do: X = np.zeros((2, 2)) X[[[0, 1], [0, 1]]] = np.array([1, 2]) X is now: [[ 1. 0.] [ 0. 2.]] Trying to do the same thing in Theano: X = theano.shared(value=np.zeros((2, 2))) X = T.set_subtensor(X[[[0, 1], [0, 1]]], np.array([1, 2])) X.eval()

What is purpose of ifelse and switch in theano?

牧云@^-^@ 提交于 2019-12-12 18:35:02
问题 I am not able to understand anything about them, I read it from http://deeplearning.net/software/theano/tutorial/conditions.html. I suppose they function like our ifelse but not able to understand how to use them. Please some guide on this. Thanks 回答1: I would think of it as just another operator that acts on three symbolic variables, if the first is true, return the second, else return the third. But for many operators (like - and + ) theano has overloaded them for symbolic variables, so

Fixing a subset weights in Neural network during training

浪子不回头ぞ 提交于 2019-12-12 16:49:46
问题 Recently, I am considering creating a customized neural network. The basic structure is the same as usually, while I want to truncate the connections between layers. For example, if I construct a network with two hidden layers, I would like to delete some weights and keep the others, like the picture below: Structure of customized neural networks Sorry I cannot embed pictures here, only links. This is not a dropout to avoid overfitting. Actually, the remained weights(connections) are

Lasagne vs Theano possible version mismatch (Windows)

ぃ、小莉子 提交于 2019-12-12 14:21:48
问题 So i finally managed to get theano up and running on the GPU using this guide. (the test code runs fine, telling me it used the GPU, YAY!!) I then wanted to try it out and followed this guide for training a CNN on digit recognition. problem is: i get errors from the way lasagne calls theano (i guess there is a version mismatch here): Using gpu device 0: GeForce GT 730M (CNMeM is disabled, cuDNN not available) Traceback (most recent call last): File "C:\Users\Soren Jensen\Desktop\CNN-test