A Basic Neural Net w/ Python in 16 Lines of Code

What is a neural network?

A neuron

Let’s get started

from random import seed, random
def initialize_network(n_input, n_hidden, n_output):
network = []
hidden_layer = [{'weights': [random() for i in range(n_inputs+ 1)]} for i in range(n_hidden)]
network.append(hidden_layer)
output_layer = [{'weights': [random() for i in range(n_hidden + 1)]} for i in range(n_outputs)]
network.append(output_layer)
seed(1)
network = initialize_network(10, 5, 10)
for layer in network:
print(layer)

--

--

--

I am an 11 year old boy and the founder of www.centeltech.com — teaching kids about HTML and CSS. I also have a website called https://freekode.centeltech.com.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Testing Your API with Postman

To Pseudocode or not to Pseudocode, that is the question.

Object vs Instance — What’s the difference?

Software testing life cycle(STLC)

Finders keepers — freeCodeCamp

Chord: A Scalable Peer-to-peer Lookup Protocol simulation using Elixir

An approach to learn a programming language.

The outside temperature project

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adith Raghav

Adith Raghav

I am an 11 year old boy and the founder of www.centeltech.com — teaching kids about HTML and CSS. I also have a website called https://freekode.centeltech.com.

More from Medium

How to implement a feedforward backpropagation neural network in Python with MNIST dataset

Relu Activation Function(ReLU)

I Finally Made a Neural Network that Learns Snake in Python

Introduction to Convolutional Neural Network