How can I feed multiple-signals into an LSTM GAN generator?

username: Ioana_Cretu
cooked: <p>I read a paper in which the authors used a generator that comprises of two LSTM layers(100 cells each), a dropout layer and a fully connected layer for generating simultaneous signals (2-lead ECG).  I try to copy their approach and feed a 750x2 signals (random noise) in an LSTM generator, hoping to get out synthetic signals similar to the ones that I feed to the Discriminator (real).  However, I just cannot understand how would that be possible without any upsamplig layer. Moreover I have the following error when I try to feed (750,2) as input_size to the LSTM layer.<br>
My code is below:</p>
<blockquote></blockquote>
<p>class Generator(nn.Module):<br>
def <strong>init</strong>(self, seq_len, features):<br>
super(Generator, self).<strong>init</strong>()<br>
self.seq_len, self.features_signals = seq_len, features</p>
<pre><code>    self.disc = nn.Sequential(
        
        nn.LSTM(input_size=(seq_len,features), hidden_size=100, num_layers=2, batch_first=True),
        nn.Dropout(0.5)
   
    )
def forward(self, x):
    return self.disc(x)
</code></pre>
<p>device =  “cuda” if torch.cuda.is_available() else “cpu”<br>
critic = Generator(750,2).to(device)</p>
<pre><code class="lang-auto">The error:

</code></pre>
<p>TypeError                                 Traceback (most recent call last)<br>
Input In [561], in &lt;cell line: 2&gt;()<br>
1 device =  “cuda” if torch.cuda.is_available() else “cpu”<br>
----&gt; 2 critic = Generator(750,2).to(device)</p>
<p>Input In [560], in Generator.<strong>init</strong>(self, seq_len, features)<br>
3 super(Generator, self).<strong>init</strong>()<br>
4 self.seq_len, self.features_signals = seq_len, features<br>
7 self.disc = nn.Sequential(<br>
8<br>
----&gt; 9     nn.LSTM(input_size=(seq_len,features), hidden_size=100, num_layers=2, batch_first=True),<br>
10     nn.Dropout(0.5)<br>
11<br>
12 )</p>
<p>File Z:\1938759\envs\pytorch\lib\site-packages\torch\nn\modules\rnn.py:673, in LSTM.<strong>init</strong>(self, *args, **kwargs)<br>
672 def <strong>init</strong>(self, *args, **kwargs):<br>
 → 673     super(LSTM, self).<strong>init</strong>(‘LSTM’, *args, **kwargs)</p>
<p>File Z:\1938759\envs\pytorch\lib\site-packages\torch\nn\modules\rnn.py:89, in RNNBase.<strong>init</strong>(self, mode, input_size, hidden_size, num_layers, bias, batch_first, dropout, bidirectional, proj_size, device, dtype)<br>
86 real_hidden_size = proj_size if proj_size &gt; 0 else hidden_size<br>
87 layer_input_size = input_size if layer == 0 else real_hidden_size * num_directions<br>
—&gt; 89 w_ih = Parameter(torch.empty((gate_size, layer_input_size), **factory_kwargs))<br>
90 w_hh = Parameter(torch.empty((gate_size, real_hidden_size), **factory_kwargs))<br>
91 b_ih = Parameter(torch.empty(gate_size, **factory_kwargs))</p>
<p>TypeError: empty(): argument ‘size’ must be tuple of ints, but found element of type tuple at pos 2</p>
<pre><code class="lang-auto"></code></pre>

username: ptrblck
cooked: <aside class="quote no-group" data-username="Ioana_Cretu" data-post="1" data-topic="159843">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ioana_cretu/48/52645_2.png" class="avatar"> Ioana_Cretu:</div>
<blockquote>
<p>----&gt; 9 nn.LSTM(input_size=(seq_len,features), hidden_size=100, num_layers=2, batch_first=True),</p>
</blockquote>
</aside>
<p>Initialize the <code>nn.LSTM</code> with an <code>int</code> value in the <code>input_size</code> argument as you are currently passing a <code>tuple</code> to it.</p>

username: Ioana_Cretu
cooked: <p>Thank you, it worked! Please accept my apologies for answering so late!</p>