theano

How to lay out training data with stateful LSTMs and batch_size > 1

社会主义新天地 提交于 2019-12-12 12:31:56
问题 Background I would like to do mini-batch training of "stateful" LSTMs in Keras. My input training data is in a large matrix "X" whose dimensions are m x n where m = number-of-subsequences n = number-of-time-steps-per-sequence Each row of X contains a subsequence which picks up where the subsequence on the preceding row leaves off. So given a long sequence of data, Data = ( t01, t02, t03, ... ) where "tK" means the token at position K in the original data, the sequence is layed out in X like

What is the prupose/meaning of passing “input” to a function in Theano?

不羁的心 提交于 2019-12-12 12:17:23
问题 Example will make that clearer I hope, (This is a Logistic Regression object, the Theano Tensor library is imported as T) def __init__(self, input, n_in, n_out): #Other code... self.p_y_given_x = T.nnet.softmax(T.dot(input, self.W) + self.b) Which is called down in main... def main(): x = T.matrix() classifier = LogisticRegression(input=x, n_in=28 * 28, n_out=10) If these snippits aren't enough to get an understanding, the code is on this page under "Putting it All Together"- http:/

Initializing a symmetric Theano dmatrix from its upper triangle

落爺英雄遲暮 提交于 2019-12-12 12:06:00
问题 I'm trying to fit a Theano model that is parametrized in part by a symmetric matrix A . In order to enforce the symmetry of A , I want to be able to construct A by passing in just the values in the upper triangle. The equivalent numpy code might look something like this: import numpy as np def make_symmetric(p, n): A = np.empty((n, n), P.dtype) A[np.triu_indices(n)] = p A.T[np.triu_indices(n)] = p # output matrix will be (n, n) n = 4 # parameter vector P = np.arange(n * (n + 1) / 2) print

merging recurrent layers with dense layer in Keras

痴心易碎 提交于 2019-12-12 08:53:54
问题 I want to build a neural network where the two first layers are feedforward and the last one is recurrent. here is my code : model = Sequential() model.add(Dense(150, input_dim=23,init='normal',activation='relu')) model.add(Dense(80,activation='relu',init='normal')) model.add(SimpleRNN(2,init='normal')) adam =OP.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08) model.compile(loss="mean_squared_error", optimizer="rmsprop") and I get this error : Exception: Input 0 is incompatible with

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

怎甘沉沦 提交于 2019-12-12 08:16:19
问题 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))

Deconvolution2D layer in keras

六眼飞鱼酱① 提交于 2019-12-12 07:12:51
问题 This layer in not ready documented very well and I'm having a bit of trouble figuring out exactly how to use it. I'm Trying something like: input_img = Input(shape=(1, h, w)) x = Convolution2D(16, 7, 7, activation='relu', border_mode='valid')(input_img) d = Deconvolution2D(1, 7, 7, (None, 1, 2*h, 2*w)) x = d(x) but when I try to write d.output_shape , I get the original shape of the image instead of twice that size (which is what I was expecting). Any help will be greatly appreciated! 回答1:

Selecting number of strides and filters in CNN (Keras)

大兔子大兔子 提交于 2019-12-12 04:55:23
问题 I am using keras to build a cnn model for signal classification. What is the best way in keras for hyper parameter tuning and selection for the number of strides,and number filters. 回答1: Welcome to main question of deep learning. There is no valid, single solution which fits to all problems. There are some patterns though, like starting with few filters in early layers and increase filter count while reducing the sizes. For you, the best would be to start reading existing architectures like

Theano Cost Function, TypeError: Unknown parameter type: <class 'numpy.ndarray'>

做~自己de王妃 提交于 2019-12-12 04:48:26
问题 I'm new to Theano, just learning it. I have a ANN in python that I'm implementing in Theano as learning process. I'm using Spyder. And Theano throws out an error: TypeError: Unknown parameter type: class 'numpy.ndarray' I'm not sure where the error is. Is it in the cost function or in the gradient descent? And what is the typical reason for it? Here is my code: X = T.dmatrix() y = T.dmatrix() X_input = np.genfromtxt('X.csv',delimiter=',') #5000x195 y_input = np.genfromtxt('y.csv',delimiter=',

Using PYMC3 on Windows 10 - theano cannot import name 'floatX'

牧云@^-^@ 提交于 2019-12-12 04:19:24
问题 I'm struggling to get PYMC3 to install correctly on windows. I've tried using the Anaconda package via conda install -c conda-forge pymc3 and in a virtualenv using only pip as per the documentation. It seems to install ok, but fails when running an import pymc3 with the following error. Research suggests that there may be some dependencies which are getting missed. >>> import pymc3 WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10).

regarding transforming an ndarray(image input via cv2 or skimage) to a tensor

纵然是瞬间 提交于 2019-12-12 03:45:41
问题 I have read an image as follows using opencv image = cv2.imread('/data/TestImages/cat.jpg',cv2.IMREAD_UNCHANGED) This read image cause the error message when it was called by segmentation, np_image, np_logits = sess.run([pred, image, logits]) The error message is as TypeError: Can not convert a ndarray into a Tensor or Operation. Are there any mechanisms that can transform an image represented as ndarray to a Tensorflow tensor. Thanks. 回答1: You have to read up on the sess.run function. In the