KaiTorch
KaiTorch is a deep learning library that dynamically builds a neural network as a decentralized acyclic graph (DAG) of Scalar values and implements backprop using reverse-mode autodiff. Heavily over-commented, highly impractical, but hopefully educational.
It implements a Keras-like API that allows you to build models using a Sequential class with Dense and Dropout layers, with implementations of several commonly used weight initializers, activation functions, optimizers, and loss functions.
This project was inspired by and is an extension of Andrej Karpathy's micrograd :)
Installation
pip install kaitorch
Tutorial Notebooks
- Functions and Gradients
- Jupyter Notebook // Google Colab
- keywords: functions, derivatives, gradients
- Functions as a Feed Forward Neural Net
- Jupyter Notebook // Google Colab
- keywords: directed acyclic graph, operator overloading, magic methods, recursion
- Reverse-mode Autodiff and Backpropogation
- Jupyter Notebook // Google Colab
- keywords: chain rule, reverse-mode autodiff, topological sort, backprop
- Activation Functions
- Jupyter Notebook // Google Colab
- keywords: sigmoid, tanh, ReLU, LeakyReLU, ELU, swish
- Multi-layer Perceptron and Weight Initialization
- Jupyter Notebook // Google Colab
- keywords: dense layer, multi-layer perceptron, weight initialization, sequential class
- Loss Functions
- Jupyter Notebook // Google Colab
- keywords: mean squared error, binary crossentropy, categorical crossentropy
- Gradient Descent and Optimizers (*personal favorite)
- Jupyter Notebook // Google Colab
- keywords: gradient descent, learning rate, momentum, adagrad, rmsprop, adam
- Inverted Dropout
- Jupyter Notebook // Google Colab
- keywords: dropout layer, inverted dropout, regularization
Example Notebooks
- Regression
- Jupyter Notebook // Google Colab
- Binary Classification
- Jupyter Notebook // Google Colab
- Multi-class Classification
- Jupyter Notebook // Google Colab
Keras-esque API
Building a Neural Net
from kaitorch.models import Sequential
from kaitorch.layers import Dense, Dropout
from kaitorch.losses import CategoricalCrossentropy
from kaitorch.optimizers import Adam
from kaitorch.activations import LeakyReLU
from kaitorch.initializers import LecunNormal
model = Sequential()
model.add(Dense(12, activation='sigmoid', initializer='he_normal'))
model.add(Dropout(0.25))
model.add(Dense(12, activation=LeakyReLU(alpha=0.01), initializer=LecunNormal()))
model.add(Dense(3, activation='softmax'))
model.compile(
optimizer=Adam(lr=0.025),
loss=CategoricalCrossentropy()
)
Training a Neural Net
history = model.fit(X_train, y_train, epochs=32)
y_pred = model.predict(X_test)
Tracing/Visualization
model.plot_model(filename='trace')
Metadata
Release files for kaitorch 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kaitorch-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for kaitorch-0.1.0-py3-none-any.whl |
Release files / kaitorch-0.1.0-py3-none-any.whl
| Download URL | kaitorch-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30162157a60146153be0352fbe6ce6f3a133f6a20ecd0c4a2cfb6c0869cab026
|
|
BLAKE2b-256 checksum How to use checksums |
672fc8c695b3c6462d0fc519d12569e01a7cc2cb5ab130810cb800e061712448
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.7
|
Security for kaitorch 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.