How does the “view” method work in PyTorch?

后端 未结 8 2038
别那么骄傲
别那么骄傲 2020-12-07 07:14

I am confused about the method view() in the following code snippet.

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__in         


        
8条回答
  •  执念已碎
    2020-12-07 07:22

    I really liked @Jadiel de Armas examples.

    I would like to add a small insight to how elements are ordered for .view(...)

    • For a Tensor with shape (a,b,c), the order of it's elements are determined by a numbering system: where the first digit has a numbers, second digit has b numbers and third digit has c numbers.
    • The mapping of the elements in the new Tensor returned by .view(...) preserves this order of the original Tensor.

提交回复
热议问题