I'm trying to create a Neuron class in theano. It takes in a vector, a 
matrix, an int and optionally another vector as inputs (all theano 
variables). Using these, it creates a representation for a neuron which is 
basically another theano variable (vector). All theano operations will be 
defined on this vector as they would in any theano vector. The code, if it 
was pure python would look like this.


class Neuron:
    def __init__(self, inp, weight_store, weight_store_key=None, 
n_hidden_units=None, hidden_inp=None):
        if n_hidden_units and hidden_inp:
            pass
        elif not (n_hidden_units or hidden_inp):
            raise TypeError('__init__ takes in three or four arguments. Only 
two passed ')
        self.input = inp
        # hidden inp needs to be a 2D tensor
        assert hidden_inp.ndim == 2, (
            'Input needs to have 2 dimensions. Provided input with 
{}'.format(hidden_inp.ndim))
        if not weight_store_key:
            weight_store_key = hidden_inp.shape[0]
        self.weight = weight_store[weight_store_key]
        if hidden_inp:
            self.hidden_input = hidden_input.dot(self.weight)
        else:
            self.hidden_input = nt.zeros(shape=n_hidden_units, 
dtype=self.input.dtype)

        return nt.concatenate([self.input, self.hidden_input])



How do I achieve this in theano?

-- 

--- 
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