Skip to main content

基于 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

支持的层

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.1.0.tar.gz (13.5 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.1.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for letsann-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15522837d8a5f0ad04bd38636a4fcbe2923e162b53a552984d8be5a4530f1cf7
MD5 2562cdc9f12fa8e170696eb0211d2368
BLAKE2b-256 d2b32aab50024ab6ca55a36ae905bf7eba05421ea1141b53733c2f69ad7e0612

See more details on using hashes here.

File details

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

File metadata

  • Download URL: letsann-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90d4b3664a5ba3f6c54f94ab7ecb83f1340ff809b94ae7cda88cb3f8a757d18e
MD5 ed85b4bae3ecfd7f2017852cc2b5bfcd
BLAKE2b-256 f0af2de9ce750afb5cf7cdf5d4cdca79dda34bd0a69be3463495a15088891afc

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