Skip to main content

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

支持的层

InputDenseDropoutBatchNormalizationFlattenActivationConv2DMaxPooling2D。全部在 letsann/layers.py 中注册,想扩展就 往 LAYER_REGISTRY 里加一条即可。

数据集格式

  • CSV / TSV:默认最后一列为标签;用 target="col" 指定其它列。
  • NPZ:需要包含 Xy 两个数组。

发布到 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

Release files for LetsANN 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LetsANN 0.3.0
File Size Uploaded
letsann-0.3.0.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for LetsANN 0.3.0
File Interpreter ABI Platform
letsann-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / letsann-0.3.0.tar.gz

Download URL letsann-0.3.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b9f12220364f8840fd738d8c6534f789f5b2b2fc72165c8f51a0570186a196b1
BLAKE2b-256 checksum
How to use checksums
e89c2f7a17a602d8deef7a5b96899f0a4dc3cbc4e4d105f4dbdb5598b10655b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / letsann-0.3.0-py3-none-any.whl

Download URL letsann-0.3.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8568d3c67e98aacd4294948af44931030b55b147fe60460c1c424f527e15dc54
BLAKE2b-256 checksum
How to use checksums
80c9463d6876deedfa02b674a10fe128591e2ad5cb5329402d7bc035e44c0f9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page