Why is pytorch softmax function not working?
so this is my code
import torch.nn.functional as F
import torch

inputs = [1,2,3]
input = torch.tensor(inputs)
output = F.softmax(input, dim=1)
print(output)

is the reason why the code not working because of the dim?
the error here:
  File &quot;c:\Users\user\Desktop\AI\pytorch_jovian\linear_reg.py&quot;, line 19, in &lt;module&gt;
    output = F.softmax(input, dim=1)
  File &quot;C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\functional.py&quot;, line 1583, in softmax
    ret = input.softmax(dim)
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)



Apart from dim=0, there is another issue in your code. Softmax doesn't work on a long tensor, so it should be converted to a float or double tensor first
&gt;&gt;&gt; input = torch.tensor([1, 2, 3])
&gt;&gt;&gt; input
tensor([1, 2, 3])

&gt;&gt;&gt; F.softmax(input.float(), dim=0)
tensor([0.0900, 0.2447, 0.6652])

