Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
PyTorch Tensor Function Examples
Subtitle Here
PyTorch is a popular platform used in Machine Learning. The functions described belove are only a sample of the many tools that can be used when creating models. It is always satisfactory to see familiar concepts presented in many concepts.
- torch.sigmoid
- torch.argmax
- torch.t
- torch.transpose
- function 5
# Import torch and other required modules
import torch
Function 1 - torch.sigmoid
Besides regression, logistic regression is the next major approach used when considering an output that would be binary. Classification is the more widely-used and less scary term associated.
The Sigmoid function would be used in calculations such as cost functions.
The equation is: output = 1/1+e^-input
# Example 1 - working (change this)
#torch.tensor([[1, 2], [3, 4.]])
a = torch.randn(6)
a
tensor([ 1.1267, -0.1876, -1.1988, 0.2699, -0.3953, 0.6905])
torch.sigmoid(a)
tensor([0.7552, 0.4532, 0.2317, 0.5671, 0.4025, 0.6661])