Exercise

Your first neural network in PyTorch

A logistic regression model can be considered a small neural network with a single linear layer followed by a sigmoid function. However, you will typically use more than one linear layer when implementing neural networks.

In this exercise, you will implement a small neural network containing two linear layers. You can use as many activation functions as you want. The first layer takes an eight-dimensional input, and the last layer outputs a one-dimensional tensor.

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

Instructions

100 XP
  • Create a neural network that takes a tensor of dimensions 1x8 as input and outputs a tensor of dimensions 1x1.