pytorch view() function

    a=torch.Tensor([[[1,2,3],[4,5,6]]])
    b=torch.Tensor([1,2,3,4,5,6])

    print(a.view(1,6))
    print(b.view(1,6))

The results obtained are all tensor([[1., 2., 3., 4., 5., 6.]])

Look at another example:

    a=torch.Tensor([[[1,2,3],[4,5,6]]])
    print(a.view(3,2))

Will get:

    tensor([[1., 2.],
            [3., 4.],
            [5., 6.]])

 

Guess you like

Origin blog.csdn.net/qq_16792139/article/details/114403058