How to give single number parameter in PyTorch?
I want to use a single number as a parameter.
I tried to insert parameter as follows
self.p1 = nn.Parameter() in   def __init__(self, ...)
and self.p1 = 1.0 in def _initialize(self):
But I am getting the error
    raise TypeError(&quot;cannot assign '{}' as parameter '{}' &quot;
TypeError: cannot assign 'float' as parameter 'p1' (torch.nn.Parameter or None expected)

How can I use a single number as a parameter in my model initialized with 1?

The argument passed to nn.Parameter should be a torch.Tensor:
&gt;&gt;&gt; self.p1 = nn.Parameter(torch.tensor([1.0]))

