Pytorch-like Neural Network framework
Project description
dnnpy Framework
Installation
pip install dnnpy
Example usage
from dnnpy.activations import ReLU
from dnnpy.data import make_regression_data
from dnnpy.layers import Sequential, Dense, Dropout
from dnnpy.loss_functions import MAELoss
from dnnpy.optimizers import Adam
from dnnpy.train import train
from dnnpy.utils import split_data
import matplotlib.pyplot as plt
n_inputs = 10
hidden_units = 32
n_outputs = 1
x, y = make_regression_data(n_samples=1000, n_features=n_inputs, n_labels=1)
(x_train, y_train), (x_test, y_test) = split_data(x, y, ratio=0.7)
model = Sequential(Dense(in_features=n_inputs, out_features=hidden_units, activation=ReLU()),
Dropout(0.3),
Dense(in_features=hidden_units, out_features=n_outputs))
opt = Adam(model.parameters(), lr=1e-3)
loss_func = MAELoss()
train_loss, valid_loss = train(data=(x_train, y_train), network=model, loss=loss_func, optimiser=opt, epochs=30,
batch_size=16)
plt.plot(train_loss, label='train')
plt.plot(valid_loss, label='val')
plt.legend()
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dnnpy-0.0.1.tar.gz
(17.5 kB
view details)
Built Distribution
dnnpy-0.0.1-py3-none-any.whl
(21.0 kB
view details)
File details
Details for the file dnnpy-0.0.1.tar.gz
.
File metadata
- Download URL: dnnpy-0.0.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f38c126f976305b50c9f6c33a822d476c9ddd823a20c0ca4a9734f988d89b834 |
|
MD5 | fa33ddaf99cb81e1487c12552f1248d4 |
|
BLAKE2b-256 | 6eb66bc1e4fefd9b20f22f825ac9218cdb33b8445930fc7d98c0d3343e7d4c87 |
File details
Details for the file dnnpy-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: dnnpy-0.0.1-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 384f98514e192fdfab5bf8a33be83a705b08919b0d17e8c4378fd69cbf11a5f5 |
|
MD5 | 6545ed4adde9c8aee3bed2024cce4a95 |
|
BLAKE2b-256 | 9e2df2f12f7ddd671f418dcd38a87bbbb661d6fb8902fadc045332d186963583 |