• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build neural networks based only on Numpy

Simple Neural Networks

This is a repo for building a simple Neural Net based only on Numpy.

The usage is similar to Pytorch. There are only limited codes involved to be functional. Unlike those popular but complex packages such as Tensorflow and Pytorch, you can dig into my source codes smoothly.

The main purpose of this repo is for you to understand the code rather than implementation. So please feel free to read the codes.

Simple usage

Build a network with a python class and train it.

import npnet

class Net(npnet.Module):
    def __init__(self):
        super().__init__()
        self.l1 = npnet.layers.Dense(n_in=1, n_out=10, activation=npnet.act.tanh)
        self.out = npnet.layers.Dense(10, 1)

    def forward(self, x):
        x = self.l1(x)
        o = self.out(x)
        return o

The training procedure starts by defining an optimizer and loss.

net = Net()
opt = npnet.optim.Adam(net.params, lr=0.1)
loss_fn = npnet.losses.MSE()

for _ in range(1000):
    o = net.forward(x)
    loss = loss_fn(o, y)
    net.backward(loss)
    opt.step()

Demo

Install

pip install npnet

Download or fork

Download link

Fork this repo:

$ git clone https://github.com/MorvanZhou/npnet.git

Results

img

More Repositories

1

tutorials

机器学习相关教程
Python
11,650
star
2

Reinforcement-learning-with-tensorflow

Simple Reinforcement learning tutorials, 莫烦Python 中文AI教学
Python
8,810
star
3

PyTorch-Tutorial

Build your neural network easy and fast, 莫烦Python中文教学
Jupyter Notebook
8,075
star
4

Tensorflow-Tutorial

Tensorflow tutorial from basic to hard, 莫烦Python 中文AI教学
Python
4,325
star
5

Evolutionary-Algorithm

Evolutionary Algorithm using Python, 莫烦Python 中文AI教学
Python
1,187
star
6

NLP-Tutorials

Simple implementations of NLP models. Tutorials are written in Chinese on my website https://mofanpy.com
Python
898
star
7

easy-scraping-tutorial

Simple but useful Python web scraping tutorial code.
Jupyter Notebook
778
star
8

pytorch-A3C

Simple A3C implementation with pytorch + multiprocessing
Python
604
star
9

morvanzhou.github.io

莫烦Python Website source code
HTML
576
star
10

train-robot-arm-from-scratch

Build environment and train a robot arm from scratch (Reinforcement Learning)
Python
365
star
11

mnistGANs

Some implementations of GAN.
Python
213
star
12

Tensorflow-Computer-Vision-Tutorial

Tutorials of deep learning for computer vision.
Python
210
star
13

Tensorflow2-Tutorial

Tensorflow 2.0 toy examples
Python
209
star
14

sudoku

A simple Sudoku generator and solver. 数独生成器和解题器
Python
168
star
15

train-classifier-from-scratch

Machine Learning: Collect data online and train a classifier from scratch
Python
59
star
16

anime-StyleGAN

style mixing for animation face
Python
48
star
17

rethink

Beyond notes, record and expand your thoughts, assisting you in efficient growth.
Python
43
star
18

mevo

Evolutionary algorithms, alternative to Reinforcement Learning
Python
36
star
19

my_research

机器学习的研究
Python
35
star
20

Meta-Learning

Python
34
star
21

tfnn

A high level API based on Tensorflow
Python
29
star
22

Computer-Vision

Toy implementations of CNNs
Python
27
star
23

go-unit-test-demo

some golang unit test demos
Go
19
star
24

celebA-cyclegan

An implementation of cycle-gan that trains on celebA dataset
Python
19
star
25

mmaze

A python maze generator and solver
Python
18
star
26

pathfind

path finding algorithms
Python
18
star
27

RLarm

Python
16
star
28

A-star-maze

A* (A-Star) algorithm for finding the shortest path in a maze
Python
15
star
29

cifar-gan

Python
13
star
30

celebA-styleGAN

Python
12
star
31

celebA-gan

This experiment is an implementation of combining ACGAN and WGAN with gradient penalty. Generating images that look like the people in CelebA dataset.
Python
8
star
32

rlearn

A Python Reinforcement Learning Package
Python
7
star
33

ngrad

Python
7
star
34

cifar

Python
6
star
35

whenact

Conditional decision flow
Python
5
star
36

bezierview

bezier curve animation play
Python
3
star
37

git-demo

demo for the usage of github
Python
2
star
38

marchingSquares

Python
2
star