Search code examples
pythontheano

Theano: using dot "T" at the end of a dot product where number of dimensions is greater than one


I was going through an LSTM code by Jonathan Raiman and I encountered this line of code in "Layer" class

if x.ndim > 1:
    return  T.nnet.sigmoid(T.dot(self.linear_matrix,x.T)  + self.bias_matrix[:,None]).T  

T is "import theano.tensor as T"

x is a symbolic variable

what does x.T do? what does that (return statement).T do??

Please help.


Solution

  • x.T is the transpose of the matrix x.

    .T is a notation that applies transpose to numpy matrices, which is the same as numpy.transpose(x). It should not be confused with the name T from import theano.tensor as T

    And

    (return statement).T

    returns the transpose of the output of the sigmoid function applied on the parameter: T.dot(self.linear_matrix,x.T) + self.bias_matrix[:,None]