Pytorch part 2

cont.

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

TENSORS

  • 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 .

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store