Skip to content

Commit

Permalink
PyTorch nn Layers entry (#5586)
Browse files Browse the repository at this point in the history
* created dir and initial document

* added term entry template to layers.md

* completed meta data section with all fields updated with revelant information

* updated description section

* updated description section

* finished syntax and example sections

* cleaned up document spacing

* cleaned up document spacing, fixed errors and typos

* deleted addon created file and document not associated with the prject

* Update content/pytorch/concepts/nn/terms/layers/layers.md

Updated "CatalogContent" section per suggested change.

* Update content/pytorch/concepts/nn/terms/layers/layers.md

Updated "Title" per Suggested change.

* Updated Opening paragraph per suggestion

* Updated description to reflect opening paragraph

* Updated syntax paragraph to suggested change

* Update content/pytorch/concepts/nn/terms/layers/layers.md

Updated section code per suggested change.

* Update content/pytorch/concepts/nn/terms/layers/layers.md

Updated code example paragraph per suggested change.

* Update content/pytorch/concepts/nn/terms/layers/layers.md

Updated the code example per the suggested change.

* Update content/pytorch/concepts/nn/terms/layers/layers.md

* Update content/pytorch/concepts/nn/terms/layers/layers.md

* Update layers.md

fixed formating issue

* Update layers.md

* Update layers.md

* Update layers.md

fixed formatting

---------
  • Loading branch information
DigitalDruid10010110 authored Nov 15, 2024
1 parent cd31ae8 commit 994c765
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions content/pytorch/concepts/nn/terms/layers/layers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
Title: 'Layers'
Description: 'Layers are modules that perform operations on input data to build neural networks.'
Subjects:
- 'AI'
- 'Machine Learning'
Tags:
- 'AI'
- 'Deep Learning'
- 'Machine Learning'
- 'Models'
- 'Neural Networks'
CatalogContent:
- 'learn-intro-to-py-torch-and-neural-networks'
- 'py-torch-for-classification'
- 'paths/machine-learning'
---

**Layers** are modules that perform operations on input data to build neural networks.

## Syntax

By using PyTorch's `.Sequential()` method to build a neural network, we can specify layers and activation functions in sequence from input to output as shown below:

```pseudo
import torch
import torch.nn as nn
# Define the model for the neural network
model = nn.Sequential(
# Define layers and activation functions here
nn.Linear(in_features, out_features),
nn.ReLU(),
nn.Linear(in_features, out_features)
)
```

## Example

Below is an example of a basic multi-layer neural network defined using PyTorch's `nn.Sequential()` method, where the data is processed through a specified sequence of layers and activation functions:

```py
import torch
import torch.nn as nn

model = nn.Sequential(
# First layer: Linear transformation from 56 input features to 128 output features
nn.Linear(56, 128), # This layer learns to transform input data
nn.ReLU(), # Activation function to introduce non-linearity

# Second layer: Linear transformation from 128 input features to 26 output features
nn.Linear(128, 26), # This layer continues to transform the data
nn.ReLU(), # Another activation function for non-linearity

# Third layer: Linear transformation from 26 input features to 1 output feature
nn.Linear(26, 1) # Final output layer that produces the model's prediction
)
```

0 comments on commit 994c765

Please sign in to comment.