Get startedGet started for free

The sigmoid and softmax functions

The sigmoid and softmax functions are key activation functions in deep learning, often used as the final step in a neural network.

  • Sigmoid is for binary classification
  • Softmax is for multi-class classification

Given a pre-activation output tensor from a network, apply the appropriate activation function to obtain the final output.

torch.nn has already been imported as nn.

This exercise is part of the course

Introduction to Deep Learning with PyTorch

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

input_tensor = torch.tensor([[2.4]])

# Create a sigmoid function and apply it on input_tensor
sigmoid = nn.____()
probability = ____(____)
print(probability)
Edit and Run Code