Pytorch part 2

Adarsha Regmi
Feb 24, 2022

--

cont.

Similar to numpy where exist multi-dimensional array, the pytorch tensorflow are build up of tensors.

TENSORS

ever heard of it. Let’s begin.

  • They are same as numpy arrays except that they have flexibility to run in GPU.

Types of

  1. FloatTensor: 32-bit float
  2. DoubleTensor: 64-bit float
  3. HalfTensor: 16-bit float
  4. IntTensor: 32-bit int
  5. LongTensor: 64-bit int
tensor vs nd array

some basic functions

  • torch.add()
  • torch.sub()
  • torch.mm() <matrix multiplication>
  • torch.div()
  • torch.t()
  • torch.cat()
  • a.reshape()

# converting the numpy array to tensor

  • tensor = torch.from_numpy(a)

In next section lets discuss more about the common pytorch Modules… part 3 .

--

--