Pytorch part 2

TENSORS

ever heard of it. Let’s begin.

  • They are same as numpy arrays except that they have flexibility to run in GPU.
  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
  • torch.add()
  • torch.sub()
  • torch.mm() <matrix multiplication>
  • torch.div()
  • torch.t()
  • torch.cat()
  • a.reshape()
  • tensor = torch.from_numpy(a)

--

--

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