<jupyter_start><jupyter_text>[Three Ways to Build a Neural Network in PyTorch](https://towardsdatascience.com/three-ways-to-build-a-neural-network-in-pytorch-8cea49f9a61a)===![](https://miro.medium.com/max/4808/0*-LGdeEFr6ljbfqm5) ![](https://miro.medium.com/max/1972/1*QQk0h-t7fT74ekdH6h7ShA.png)So this is a Fully Connected 16x12x10x1 Neural Network witn relu activations in hidden layers, sigmoid activation in output layer. 1. Manually building weights and biases- This is a low level approach, but it may be suited if you’re trying to reproduce the latest and greatest deep learning architecture on a paper you just just read. Or maybe if you want to develop a customized layer.- The key thing here is that you will need to tell PyTorch what is **_variable_** or **_optimizable_** in your network, so that PyTorch knows how to perform **gradient descent** on your network.<jupyter_code>import torch
import torch.nn.functional as F

torch.manual_seed(42)

# generating some random features
features = torch.randn(1, 16) 

# define the weights
W1 = torch.randn((16, 12), requires_grad=True)
W2 = torch.randn((12, 10), requires_grad=True)
W3 = torch.randn((10, 1), requires_grad=True)

# define the bias terms
B1 = torch.randn((12), requires_grad=True)
B2 = torch.randn((10), requires_grad=True)
B3 = torch.randn((1), requires_grad=True)

# calculate hidden and output layers
h1 = F.relu((features @ W1) + B1)
h2 = F.relu((h1 @ W2) + B2)
output = torch.sigmoid((h2 @ W3) + B3)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.045755968169761276, 'mean_word_length': 5.261410788381743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '374753', 'license': 'MIT', 'n_tokens_mistral': 556, 'n_tokens_neox': 513, 'n_words': 165, 'path': '03_Three_Ways_to_Build_Neural_Nets.ipynb', 'repo_name': 'Shahid1993/pytorch-notebooks', 'size': '1508'}