Skip to main content

A package designed for the newer about the Neural Network.

Project description

FoolNet - v0.1.2

A package designed for the new hand about the Neural Network and Deep Learning.

Not used for the application but for the learning purpose with easy-reading code.

Introduction

Through the source code of this package, equipped with the awesome website we built, you're able to know more clearly about how the Neural Network work.

In this package, all the components of Neural Network, such as activation, loss function, BP algorithm are built from scratch, totally via the numpy! Therefore you can easily read the code and understand the meaning of this part without extra effort.

What's more, we created a website for the users to understand the mathematical logic behind the code, and why we implement it in that way, so users can understand some deeper principles, and not only 'How can I use it'.

The Package

Installation

Just use pip to install it from PypI. We maintain it for free!

pip install foolnet

Requirements: python >= 3.9 ; numpy >= 1.20.0; matplotlib >= 3.8.0

Usage

A usage example under version 0.1.2.

import numpy as np
import foolnet as fn

func = lambda x: np.log(1 / (np.sin(x) + 2)) # 生成具有非线性可分性的数据
dataset = fn.ClassificationDataset(x_dim=2, n_class=3, nums=999, nonlinear_fn=func)

# 两层网络
dense1 = fn.DenseLayer(2, 3, fn.ReLU())
dense2 = fn.DenseLayer(3, 3, fn.Softmax())

lossfn = fn.CrossEntropyLoss()

for i in range(10):
    loss, acc = np.array([]), np.array([])
    for x, y in dataset.trainset:
        # 前向传播
        dense1.forward(x)
        dense2.forward(dense1.output)

        loss = np.append(loss, lossfn(dense2.output, y))

        # 反向传播
        lossfn.backward(dense2.output, y)
        dense2.backward(lossfn.dinputs)
        dense1.backward(dense2.dinputs)

        dense1.update(0.5)
        dense2.update(0.5)

    # 在测试集上计算准确率
    for x, y in dataset.testset:
        dense1.forward(x)
        dense2.forward(dense1.output)

        acc = np.append(acc, np.mean(np.argmax(dense2.output, axis=1) == y))

    print(f"epoch{i} loss {np.mean(loss):.5f} acc {np.mean(acc):.5f}\n")

dataset.show()

The Website

The website is built by @CoderSerio, with the dumi framework.

Online

For online website, you may goto https://lazypool.github.io/foolnet/.

Offline

For you wish downloading the documents to your local, just clone this repository.

git clone 'git@github.com:lazypool/foolnet.git'
cd foolnet/docs/

Then run the next commands, supose that you have downloaded the npm.

$ npm install
$ npm run start

Now you should be able to visit the website at https://localhost:8000, which has the same content with the online website.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foolnet-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

foolnet-0.1.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file foolnet-0.1.2.tar.gz.

File metadata

  • Download URL: foolnet-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for foolnet-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e37bebe12669df190301deabc245bdd0ad6755d92f118711812d87cbb15ebf89
MD5 69adb56f31a0d21c4c043c6279dfe154
BLAKE2b-256 3500d77671c8acb22fc1f81b3ad86d4e448a991f9c920d30c2a3024a411ca447

See more details on using hashes here.

File details

Details for the file foolnet-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: foolnet-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for foolnet-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe4f9c624a0e48964f70da2740379eb0c23a278650f21228bb4366f0bb817c05
MD5 de6b19509ad62f68ea8ba635552ed714
BLAKE2b-256 15a3c466dc608be4c2e6c5761fbd93563541c35b94422349c91999d84d6e5a27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page