Adding a number to the last dimension of a tensor
I am trying to add a number to a tensor, in the way that this integer will be added as a new dimension.
The tensor is 2 rows and 7 columns:
x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
x = torch.tensor(x)
x = x.reshape(-1,7)
print(x.shape)
print(x)

It results in:
torch.Size([2, 7])
tensor([[ 1,  2,  3,  4,  5,  6,  7],
        [ 8,  9, 10, 11, 12, 13, 14]])

The number is a float:
a= 0.19
b= torch.tensor([a])
b.reshape(-1,1)
b= b.unsqueeze(dim=1)
print(b.shape)
b

Which is:
torch.Size([1, 1])

tensor([[0.1900]])

What I want to generate is a [2,8] tensor:
tensor([[1,  2,  3,  4,  5,  6,  7,0.1900],
        [8,  9, 10, 11, 12, 13, 14,0.1900]])

So,I thought I can torch.stack to have a new dimension:
c= torch.stack((x, b), dim=-1)

Gives an error of : RuntimeError: stack expects each tensor to be equal size, but got [2, 7] at entry 0 and [1, 1] at entry 1
PS: I tried to reshape x into a shape of [14,1] and added [1,1] float tensor to make [15,1], but it added only once so I cannot make a new [2,8] anymore.
x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
x = torch.tensor(x)
x = x.reshape(-1,1)
print(x.shape)
print(x)
torch.Size([14, 1])
tensor([[ 1],
        [ 2],
        [ 3],
        [ 4],
        [ 5],
        [ 6],
        [ 7],
        [ 8],
        [ 9],
        [10],
        [11],
        [12],
        [13],
        [14]])
print('b',b)
c= torch.cat((x, b), dim=-2)
print(c.shape)
b tensor([[0.1900]])
torch.Size([15, 1])

I would be happy to have some help!

You need to expand tensor b before concatenating them:
import torch
x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
x = torch.tensor(x)
x = x.reshape(-1,7)
a=0.19
b= torch.tensor([a])

torch.cat((x,b.expand((2,1))),dim=1)

Will give:
tensor([[ 1.0000,  2.0000,  3.0000,  4.0000,  5.0000,  6.0000,  7.0000,  0.1900],
        [ 8.0000,  9.0000, 10.0000, 11.0000, 12.0000, 13.0000, 14.0000,  0.1900]])

