PyTorch equivalent of a Tensorflow linear layer
I was trying to reimplement a Tensorflow code using PyTorch framework. Below I have included the TF sample code and my PyT interpretation.

TensorFlow implementation:

W1 = tf.Variable(xavier_init([135, 128]))
b1 = tf.Variable(tf.zeros(shape=[128]))

def fcn(x):
    z = tf.reshape(x, (-1, 135))
    out1 = leaky_relu( tf.matmul(z, W1) + b1 )

    return out1


PyTorch implementation:

class decoder(nn.Module):
    def __init__(self):
        super(decoder, self).__init__()

        self.layer_10 = nn.Linear(135, 128, bias=True)
        self.leaky = nn.LeakyReLU(0.2, inplace=False)
        init.xavier_uniform(self.layer_10.weight) 

    def forward(self, x):
        z = x.view(-1, 135)
        h30 = self.leaky(self.layer_10(z))

        return h30


I was wondering what is the proper way to implement the matmul part, given that the weights in pytorch are not explicitly defined as they are in the TF (or correct me if I'm wrong). 

You do not need to explicitly call torch.matmul: it is in the implementation of the forward method of the nn.Linear layer. By calling self.layer_10(z) you are actually calling (behind the scene) the forward method that does the matrix multiplication and adds the bias for you.

If you want your code to be exactly the same, you might want to explicitly initialize the weights using the same method. For that you have nn.init that implements a variety of weight initializations. Specifically, you might find nn.init.xavier_uniform_ relevant.
