Exercise

Building a binary classifier in PyTorch

Recall that a small neural network with a single linear layer followed by a sigmoid function is a binary classifier. It acts just like a logistic regression.

In this exercise, you'll practice building this small network and interpreting the output of the classifier.

The torch package and the torch.nn package have already been imported for you.

Instructions 1/2

50 XP
    1
    2
  • Create a neural network that takes a tensor of dimensions 1x8 as input, and returns an output of the correct shape for binary classification.
  • Pass the output of the linear layer to a sigmoid, which both takes in and return a single float.