In my CNN at some stage I want to multiply a feature map with some scalar which should be learnt by the network. The scalar has to be initialised to 5. So I think of the following solution,
def __init__(self):
    super(..., self).__init__()
    ...
    ...
    alpha = nn.Parameter(torch.ones(1)*5)
    ...

def forward(self, x):
    ...
    x = x * alpha
    return x

This should work because of the BROADCASTING SEMANTICS of PyTorch. But I wonder why or why not the following be used,
def __init__(self):
    super(..., self).__init__()
    ...
    ...
    alpha = nn.Parameter(torch.tensor(5.))
    ...

def forward(self, x):
    ...
    x = x * alpha
    return x

Surely this should work but is there any pitfall for the latter approach when compared to the first approach which uses torch.ones(1)*5. Generally I do not see people using the latter approach and use the first approach only.
Thankyou
Mohit