Hey All,
I’m building a RNN to analyze audio. My current framework is input of 10000, hidden layer of 1000, output of 1.
My code looks like this - I loosely based it on this model here 2
class discriminator(torch.nn.Module):

    def __init__(self,input_size,hidden_size):
        super(discriminator,self).__init__()
        self.input_size = input_size
        self.hidden_size = hidden_size
        self.i2h = torch.nn.Linear(input_size+hidden_size,hidden_size)
        self.i2o = torch.nn.Linear(input_size+hidden_size,1)
        self.softmax = torch.nn.LogSoftmax(dim=1)
        self.learning_rate = 0.005

    def forward(self, input, hidden):
        combined = torch.cat((input,hidden),0)
        print(combined.size())
        hidden = self.i2h(combined)
        output = self.softmax(self.i2o(combined))
        return output,hidden

    def initHidden(self):
        return torch.zeros(self.hidden_size,1)

    def train_rnn(self,input_tensor,result_tensor):

        hidden = self.initHidden()

        self.zero_grad()

        for i in range(input_tensor.size()[0]):
            output, hidden = self.forward(input_tensor[i],hidden)

        loss = torch.nn.NLLLoss(output,result_tensor)
        loss.backward()
        for p in self.parameters():
            p.data.add_(-self.learning_rate,p.grad.data)

        return output, loss.item()

I am putting in a [15,10000,1] tensor in as a test input into a discriminator with an input size of 10000 and a hidden size of 10000, and am getting this error:
Traceback (most recent call last):

  File "gan.py", line 123, in <module>

    main()

  File "gan.py", line 109, in main

    output,loss = disc.train_rnn(test[0],test[1])

  File "gan.py", line 75, in train_rnn

    output, hidden = self.forward(input_tensor[i],hidden)

  File "gan.py", line 61, in forward

    hidden = self.i2h(combined)

  File "/Users/glma2016/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in __call__

    result = self.forward(*input, **kwargs)

  File "/Users/glma2016/anaconda3/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 55, in forward

    return F.linear(input, self.weight, self.bias)

  File "/Users/glma2016/anaconda3/lib/python3.7/site-packages/torch/nn/functional.py", line 1024, in linear

    return torch.addmm(bias, input, weight.t())

RuntimeError: size mismatch, m1: [20000 x 1], m2: [20000 x 10000] at /Users/soumith/code/builder/wheel/pytorch-src/aten/src/TH/generic/THTensorMath.cpp:2070

I don’t know where this m2 is getting this mismatch from - the i2h linear layer should just be a normal linear layer. Where should I start troubleshooting?
thanks!