self.W_sub1.data will return tensor object. But the code shouldn’t be worong…Follwing code has right output
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.W_sub1 = nn.Parameter(torch.randn(2048))
    def forward(self, x):
        x = F.relu(x * self.W_sub1).unsqueeze(1)
        return x
net = Net()
x = torch.randn(2048)
y_pred

tensor([[0.1318],
        [0.0000],
        [0.0000],
        ...,
        [0.2246],
        [0.0000],
        [2.0227]], grad_fn=<UnsqueezeBackward0>)