As part of the course I’m taking now “Pytorch from zero to GANs”. I’m writing about 5 functions that I found useful, of course there are many more and they do all this heavy math operations in 1 line — how elegant pytorch is!
- torch.rand
- torch.max
- torch.log10
- torch.zeros
- torch.prod
torch.rand outputs a tensor filled with random numbers in the range (0,1) of the specified size
torch.max as the name implies returns the largest element in the tensor
torch.log10 works like a lambda function — it logarithmises to base 10 every element(it must be numeric) and returns the tensor of computed elements
torch.zeros returns a tensor of zeros of given size
torch.prod as the name implies returns the product, multiplication of all elements in the tensor, be it 2d tensor or not.
you can see the notebook here: https://jovian.ml/erjcan/01-tensor-operations-erjan