Hi,

I am constructing an antuencoder to predict word embeddings. The train 
function needs array-like object as inputs, while the weights(as target) I 
extract from embedding layer is a tensor variable. 
I know a tensor symbolic variable cannot convert to ndarray, but the input 
of a function must be ndarray.Besides, the target I extract from embedding 
layer is always a tensor variable.
Plz help me, I am new to theano and I've no idea to solve this problem 
after taking a few hours.

CODE:

import lasagne
import theano.tensor as T
import numpy as np

        l_in = InputLayer((1,None)) 

        emb = EmbeddingLayer(l_in, input_size=glove.shape[0] , output_size 
=glove.shape[1] , W = glove.astype('float32'))

        reshape = ReshapeLayer(emb, (1, 1, senlen,50))

        l_conv = Conv2DLayer(reshape, num_filters = num_filters, 
filter_size=filter_size, stride=1,nonlinearity=rectify)

        maxpool = GlobalPoolLayer(l_conv, pool_function= T.max)
 
        hid = DenseLayer(maxpool, num_units=100, nonlinearity=tanh)

        doc_emb = DenseLayer(hid, num_units=50, nonlinearity=tanh)
 

        train_X = T.imatrix()
        train_Y = T.fmatrix()
 
        loss = T.mean(lasagne.objectives.
squared_error(output, train_Y))
        params = get_all_params(decode_word[n])
        grad = T.grad(loss, params)
        updates = lasagne.updates.sgd(grad, params, learning_rate=0.5)
        f_train = theano.function([train_X,train_Y], loss, updates=updates, 
allow_input_downcast=True)
        ....
       target = get_output(emb, Input)
       loss = f_train(Input, target)   #ERROR: target is a variable, not an 
ndarray


Thanks,
Richard

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to