Skip to main content

biosnn-bus

BioSNN-Plug 的模态插件骨架库。

它只负责一件事:让新增模态不需要修改已有架构。

这是骨架,不是认知核心。 本库不包含任何学习规则(e-prop / R-STDP / 核化 IB-Hebbian)、不包含脉冲神经元模型、不依赖 GPU、不依赖 PyTorch。它提供 的是插件的接口契约、注册与发现机制、以及脉冲总线的接缝。

安装

尚未发布到 PyPI,当前从 Git 安装:

pip install "biosnn-bus @ git+https://github.com/lzmd-arch/BioSNN-Plug.git#subdirectory=packages/biosnn-bus"

# 需要 torch 桥接时(SpikeTrain.to_torch / from_torch)
pip install "biosnn-bus[torch] @ git+https://github.com/lzmd-arch/BioSNN-Plug.git#subdirectory=packages/biosnn-bus"

只依赖 numpy。

快速开始

import numpy as np
from biosnn_bus import ModalityPlugin, PassThroughMembrane, SpikeBus, SpikeTrain


class MyPlugin(ModalityPlugin):
    @property
    def modality_name(self) -> str:
        return "my_modality"

    @property
    def spike_dim(self) -> int:
        return 64

    def encode(self, raw_input):
        return SpikeTrain(data=np.asarray(raw_input) > 0.5, channel=self.channel)

    def get_membrane(self):
        return PassThroughMembrane()

    def decode(self, spike_output):
        return spike_output.rates


bus = SpikeBus(bus_dim=128, seed=0)
bus.register(MyPlugin())
out = bus.step({"my_modality": np.random.default_rng(0).random((10, 64))})
print(out)

完整可跑的版本见 examples/quickstart_register_plugin.py, 以及 Colab notebook(无 GPU 可跑)。

核心概念

概念 说明
ModalityPlugin 模态插件的抽象基类:encode / decode / get_membrane 三方法,modality_name / spike_dim 两属性
SpikeTrain 形状 (T, N) 的脉冲序列容器,布尔(脉冲)或浮点(发放率)皆可
FusionChannel temporal / semantic 两条融合通道,对应计划书 §2.2 的"双通道融合"
SpikeBus 脉冲总线:编码 → 时间对齐 → 按通道融合 → 稀疏随机投影到认知核心维度
register_plugin 进程内注册装饰器
discover_plugins 扫描第三方分发包声明的 entry points

第三方插件怎么接入

在你的包里声明 entry point,不需要修改 BioSNN-Plug 任何一行代码:

# 你的包的 pyproject.toml
[project.entry-points."biosnn_bus.plugins"]
audio = "my_pkg.plugins.audio:AudioPlugin"

用户侧扫描并接入。下面这段可以直接跑——即使一个第三方插件都没装:

from biosnn_bus import SpikeBus, discover_plugins, get_plugin, list_plugins
from biosnn_bus.plugins import DiffImagePlugin

discover_plugins()  # 扫描第三方分发包声明的插件;一个都没装也不会报错
print(list_plugins())  # 内置示例插件在 import 时已注册进注册表

bus = SpikeBus(bus_dim=128, seed=0)
bus.register(get_plugin("image_diff")())  # 等价于 bus.register(DiffImagePlugin())
print(bus)

骨架的边界

脉冲总线当前的默认融合策略是平凡的拼接(ConcatenateFusion),不是计划书 §2.2 描述的 TAAF 时间注意力引导融合——后者是第二阶段的研究任务。总线已经把 FusionStrategy 协议和双通道路由留好,替换策略不会改动调用方代码。

理由见 ADR-0001。

许可证

Apache-2.0。文档采用 CC-BY 4.0。

Metadata

Release files for biosnn-bus 0.1.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 biosnn-bus 0.1.0
File Size Uploaded
biosnn_bus-0.1.0.tar.gz 34.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for biosnn-bus 0.1.0
File Interpreter ABI Platform
biosnn_bus-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.8 kB

Release files / biosnn_bus-0.1.0.tar.gz

Download URL biosnn_bus-0.1.0.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8e9e8ce855a195fb1ce06767bde1cdfd237c0e26e7be539c92153e8b03c7b04e
BLAKE2b-256 checksum
How to use checksums
f12dec86990c3309e3ad178188f972727605f070e7f2f28805cc6ae156387248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / biosnn_bus-0.1.0-py3-none-any.whl

Download URL biosnn_bus-0.1.0-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0edb283ba383bd5e9a5e4da17b2ace7e52621d5b4e7c935b91115af879ebf7d3
BLAKE2b-256 checksum
How to use checksums
c05da80b966e54e26b9e651cff90832b667ca74a52318c53c44457aa7e5d70ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

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