Skip to content

A Toy Nerual Network Framework 自制神经网络框架

Notifications You must be signed in to change notification settings

BUAADreamer/nnplayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This repo is a Nerual Network Framework for learning Deep-Learning and Machine-Learning.

This framework refers to PyTorch's Design and Usage.

Usage

import nnplayer as npl
import numpy as np

# build net
net = npl.Sequence(npl.Linear(10, 6), npl.Sigmoid(), npl.Linear(6, 4), npl.Sigmoid())
# calculate loss 
loss = npl.MSELoss(net)
# optimizer
optimizer = npl.SGD(net.getParamsList())
# build the dataset
X = np.arange(40).reshape(4, 10)
Y = np.arange(16).reshape(4, 4)
# train
epoch = 100
for i in range(epoch):
    Y_predict = net.forward(X)
    l = loss.loss(Y_predict, Y)
    print(f'epoch{i + 1} loss:{l.mean()}')
    loss.backward()
    optimizer.step()
l = loss.loss(net.forward(X), Y)
print(l.mean())

About

A Toy Nerual Network Framework 自制神经网络框架

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages