基于 TensorFlow 的零基础 ANN 库:用简单的 Python 字典就能描述网络。
Project description
LetsANN
LetsANN 是一个基于 TensorFlow / Keras 的零基础 ANN 库。
用最简单的 Python 列表描述网络,像搭积木一样训练模型。
需要可视化拖拽界面?请看配套的独立项目
letsann-web。
安装
pip install LetsANN
要求 Python 3.8 及以上。
最小示例
from letsann import Model, load_dataset
# 用 DataFrame 或 CSV 路径都行,最后一列默认为标签
ds = load_dataset("iris.csv", target="species")
# 用列表描述网络
model = Model([
{"type": "Input", "params": {"shape": "4"}},
{"type": "Dense", "params": {"units": 16, "activation": "relu"}},
{"type": "Dense", "params": {"units": 3, "activation": "softmax"}},
])
# 和 Keras 一样编译、训练
model.compile(optimizer="adam",
loss="sparse_categorical_crossentropy",
metrics=["accuracy"])
model.fit(ds.X_train, ds.y_train,
validation_data=(ds.X_val, ds.y_val),
epochs=20, batch_size=16)
print(model.summary())
更多示例见 examples/quickstart.py。
支持的层
Input、Dense、Dropout、BatchNormalization、Flatten、Activation、
Conv2D、MaxPooling2D。全部在 letsann/layers.py 中注册,想扩展就
往 LAYER_REGISTRY 里加一条即可。
数据集格式
- CSV / TSV:默认最后一列为标签;用
target="col"指定其它列。 - NPZ:需要包含
X和y两个数组。
发布到 PyPI
# 1. 安装打包工具
pip install build twine
# 2. 打包(在本目录运行)
python -m build # 会生成 dist/LetsANN-0.1.0.tar.gz 和 .whl
# 3. 先上传到 TestPyPI 验证
twine upload --repository testpypi dist/*
# 4. 确认没问题后,正式上传 PyPI
twine upload dist/*
上传需要在 https://pypi.org 先创建账号并生成 API Token,放进
~/.pypirc 或设置环境变量 TWINE_USERNAME=__token__、
TWINE_PASSWORD=<你的 token>。
开发
pip install -e ".[dev]"
pytest
License
MIT
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
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 letsann-0.2.0.tar.gz.
File metadata
- Download URL: letsann-0.2.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e00e9c0ced9c7a69ab5dcc40a3cbbea2e4da16aa86b10a93b78d1842469c8a3c
|
|
| MD5 |
96caa58a9416ba5c02581c23af38a51f
|
|
| BLAKE2b-256 |
e6af257d10723c7ccbb6886176d5b2dd18a67548aa36f2c3483756886e0e1d5a
|
File details
Details for the file letsann-0.2.0-py3-none-any.whl.
File metadata
- Download URL: letsann-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dca94310301e52a9af40f0fa8dc88e6d3d5bf9e7ad88117964f7747ca3583921
|
|
| MD5 |
fc1b11bfd9f12a4c4fbe7cd33fad46e2
|
|
| BLAKE2b-256 |
43b559f838f286a7343a708c5f49eebfb5a6f3cc3ed81fde136ba0fbadf69fe0
|