'RuntimeError: The expanded size of the tensor (1300000) must match the existing size (80) at non-singleton dimension 0

I have following errors in my RBM code and here is the in raw.

ipykernel_18388/119274704.py in v_to_h(self, v)
     23 
     24             p_h = F.sigmoid(
---> 25                 F.linear(v, w, self.h_bias)
     26             ).to(device=device)
     27 

RuntimeError: The expanded size of the tensor (1) must match the existing size (80) at non-singleton dimension 1.  Target sizes: [1300000, 1].  Tensor sizes: [80]

I set it up self.h_bias like this.

def __init__(self, n_vis, n_hid, k, batch):
            super(RBM, self).__init__()
            self.W      = nn.Parameter(torch.randn(1, batch, device=device) * 1e-2)
            self.n_vis  = n_vis
            self.n_hid  = n_hid
            self.k      = k
            self.batch  = batch
            self.v_bias = nn.Parameter(torch.zeros(n_vis, device=device))
            self.h_bias = nn.Parameter(torch.zeros(n_hid, device=device))

h_bias role is setting output size of RBM layer. So I have to make sure does it works. please help me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source