TypeError: new() received an invalid combination of arguments

username: isaac1644
cooked: <pre><code class="lang-auto">Traceback (most recent call last):
  File "train.py", line 130, in &lt;module&gt;
    old_val_psnr, old_val_ssim = validation(Encoder, DecGen, val_data_loader, device, category)
  File "/home/chen009/Desktop/ganmethod/utils.py", line 48, in validation
    latent, mu, var = Encoder(haze)
  File "/home/chen009/Desktop/ganmethod/network.py", line 76, in __init__
    self.mu = nn.Linear(1024, nz, bias=False)
  File "/home/chen009/anaconda3/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 72, in __init__
    self.weight = Parameter(torch.Tensor(out_features, in_features))
TypeError: new() received an invalid combination of arguments - got (Tensor, int), but expected one of:
 * (torch.device device)
 * (torch.Storage storage)
 * (Tensor other)
 * (tuple of ints size, torch.device device)
      didn't match because some of the arguments have invalid types: (Tensor, int)
 * (object data, torch.device device)
      didn't match because some of the arguments have invalid types: (Tensor, int)

</code></pre>
<p>For this situation, what could I do?</p>

username: vainaijr
cooked: <p>maybe nz is a tensor, I think it should be an integer, like,</p>
<pre><code class="lang-auto">nz = 10
self.mu = nn.Linear(1024, nz, bias=False)
</code></pre>

username: varenyam_bakshi
cooked: <pre><code class="lang-auto">actions_v = torch.Tensor(actions, dtype=torch.int64).to(device)
</code></pre>
<p>I am getting error on this line of code<br>
here is the error displayed</p>
<pre><code class="lang-auto">new() received an invalid combination of arguments - got (numpy.ndarray, dtype=torch.dtype), but expected one of:
 * (torch.device device)
 * (torch.Storage storage)
 * (Tensor other)
 * (tuple of ints size, torch.device device)
      didn't match because some of the keywords were incorrect: dtype
 * (object data, torch.device device)
      didn't match because some of the keywords were incorrect: dtype
</code></pre>

username: ptrblck
cooked: <p>To create a tensor from a numpy array use <code>torch.from_numpy</code>.</p>

username: Mandeep-Rathee
cooked: <p>I am also getting the same error,</p>
<p>File “C:\Users\XYZ\Anaconda3\envs\PyTorch\lib\site-packages\torch\nn\modules\linear.py”, line 72, in <strong>init</strong><br>
self.weight = Parameter(torch.Tensor(out_features, in_features))</p>
<p>TypeError: new() received an invalid combination of arguments - got (Tensor, GCN), but expected one of:</p>
<ul>
<li>(torch.device device)</li>
<li>(torch.Storage storage)</li>
<li>(Tensor other)</li>
<li>(tuple of ints size, torch.device device)<br>
didn’t match because some of the arguments have invalid types: (!Tensor!, !GCN!)</li>
<li>(object data, torch.device device)<br>
didn’t match because some of the arguments have invalid types: (!Tensor!, !GCN!)</li>
</ul>

username: ptrblck
cooked: <p>Could you check, if you’ve redefined <code>in_features</code> as <code>GCN</code>? I don’t know what kind of type it is, but it might be a custom function?</p>

username: Mandeep-Rathee
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> thanks for your reply.</p>
<p>I was using the class without making the instance. I solved this Error just by creating the instance.</p>

username: Rexedoziem
cooked: <p>If you use tensor instead of Tensor, it’ll do the trick</p>