Skip to main content

基于 TensorFlow 的零基础 ANN 库

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

支持的层

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

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

letsann-0.3.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

letsann-0.3.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file letsann-0.3.0.tar.gz.

File metadata

  • Download URL: letsann-0.3.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for letsann-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b9f12220364f8840fd738d8c6534f789f5b2b2fc72165c8f51a0570186a196b1
MD5 82cc0c176d4888f811775564f3c8d06e
BLAKE2b-256 e89c2f7a17a602d8deef7a5b96899f0a4dc3cbc4e4d105f4dbdb5598b10655b1

See more details on using hashes here.

File details

Details for the file letsann-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: letsann-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for letsann-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8568d3c67e98aacd4294948af44931030b55b147fe60460c1c424f527e15dc54
MD5 f2e6dacbabcc7177cbdcb811fa41029c
BLAKE2b-256 80c9463d6876deedfa02b674a10fe128591e2ad5cb5329402d7bc035e44c0f9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page