A package designed for the newer about the Neural Network.
Project description
FoolNet - v0.3.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.3.2.
import numpy as np
import foolnet as fn
np.random.seed(42)
func = lambda x: np.log(1 / (np.sin(x) + 2)) # 生成具有非线性可分性的数据
dataset = fn.ClassificationDataset(x_dim=2, n_class=3, nums=999, nonlinear_fn=func)
# 两层网络
model = fn.Stack(
fn.DenseLayer(2, 3),
fn.ReLU(),
fn.DenseLayer(3, 3),
fn.Softmax()
)
lossfn = fn.CrossEntropyLoss()
for i in range(30):
loss, acc = np.array([]), np.array([])
for x, y in dataset.trainset:
# 前向传播
output = model(x)
loss = np.append(loss, lossfn(output, y))
# 反向传播
lossfn.backward(output, y)
model.backward(lossfn.dinputs)
# 更新参数
for pair in model.parameters():
pair[0] += -0.5 * pair[1]
# 在测试集上计算准确率
for x, y in dataset.testset:
output = model(x)
acc = np.append(acc, np.mean(np.argmax(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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file foolnet-0.3.2.tar.gz.
File metadata
- Download URL: foolnet-0.3.2.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dc4c891ae9e80ed2c286a7c46b598e034e515d4b710ecaa2f8e9828f421133e
|
|
| MD5 |
ad3cad3cc64781b32c84d166d30803af
|
|
| BLAKE2b-256 |
42088d4fd158e05fb0989a0e3fc85c91e294e58e0f92a4d91c594c0dcf923c3b
|
File details
Details for the file foolnet-0.3.2-py3-none-any.whl.
File metadata
- Download URL: foolnet-0.3.2-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
511022e3868929c5f0b7a892bbea1d0696b986ea8a1363657d25c30c24b7c3d2
|
|
| MD5 |
5e58ecea9ceb72cff9834277c245549a
|
|
| BLAKE2b-256 |
ff523bbdd412acd51a08c149fc3e90c8718257d3b9de4119f14f05ce46be4708
|