Skip to main content

A package designed for the newer about the Neural Network.

Project description

FoolNet - v0.2.1

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.2.1.

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.2.1.tar.gz (7.6 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.2.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for foolnet-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8ad710192ba2c49045f20575deed04263fc8afa0cbcc8ddf94eeb6d4705df8e0
MD5 1ee278fab647f38be88325a15734e039
BLAKE2b-256 842c2753d8455e16954805ae8c8283318e50d03e748e40468596087ed2d465fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: foolnet-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d83bda3847ff4df4d2a2897405483421d4ada21dda9e83b33fb8ba373614ec27
MD5 260bb8251b13b371e75fa17373329d08
BLAKE2b-256 1303322899094b4b43e51231d5deeb3e9aba50d952814f9d41dcdf9c45a0de20

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