PyTorch के साथ Deep Learning परिचय
Jasmin Ludolf
Senior Data Science Content Developer, DataCamp
$$







0 और 1 के बीच मान मिलता है
यदि आउटपुट > 0.5, class label = 1 (मेमल)
import torch import torch.nn as nn input_tensor = torch.tensor([[6]]) sigmoid = nn.Sigmoid()output = sigmoid(input_tensor) print(output)
tensor([[0.9975]])
model = nn.Sequential(
nn.Linear(6, 4), # First linear layer
nn.Linear(4, 1), # Second linear layer
nn.Sigmoid() # Sigmoid activation function
)
लिनियर लेयर्स वाले नेटवर्क में आखिरी स्टेप पर Sigmoid पारंपरिक logistic regression के equivalent होता है






import torch import torch.nn as nn # Create an input tensor input_tensor = torch.tensor( [[4.3, 6.1, 2.3]]) # Apply softmax along the last dimensionprobabilities = nn.Softmax(dim=-1) output_tensor = probabilities(input_tensor) print(output_tensor)
tensor([[0.1392, 0.8420, 0.0188]])
dim = -1 दर्शाता है कि softmax इनपुट टेन्सर के आखिरी डायमेंशन पर लागू हैnn.Softmax() को nn.Sequential() में आखिरी स्टेप के रूप में इस्तेमाल कर सकते हैंPyTorch के साथ Deep Learning परिचय