From the course: Up and Running with PyTorch by Pearson

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Multilayer feedforward neural networks (MLP)

Multilayer feedforward neural networks (MLP) - PyTorch Tutorial

From the course: Up and Running with PyTorch by Pearson

Multilayer feedforward neural networks (MLP)

So since we're adding potentially a lot of layers, if we're building a large, deep, multi-layer perceptron, I wanted to show one of the other niceties of the module API. So instead of having to write things like self.function1 or self.function2, basically explicitly having all of these just attached as attributes. We can use in PyTorch what it calls the sequential API, or the sequential container. So neuralnetwork.sequential is going to allow us to basically make a sophisticated list of layers. So we have a linear layer. In this case, let's do something a little bit more interesting. We're passing in the same single data value, a single scalar. For the first layer, let's have three output nodes. We're going to add our non-linearity, the sigmoid. So this is a one-layer perceptron. And all we need to do is copy this. Let's have three layers. And the second layer is going to take in three. So we're outputting three from the first layer. We're inputting three from the next layer. Let's…

Contents