5 分钟快速了解 NCT 的基本使用方法
pip install torch numpy scipyNCT 的核心依赖非常简单,只需要 PyTorch、NumPy 和 SciPy。建议使用 Python 3.8+ 和 PyTorch 2.0+。
from nct_modules import NCTManager, NCTConfig
# 创建配置
config = NCTConfig(
n_heads=8, # 注意力头数
n_layers=6, # Transformer 层数
d_model=768, # 模型维度
)
# 创建管理器
manager = NCTManager(config)
# 运行一个处理周期
sensory_data = generate_sensory_input()
state = manager.process_cycle(sensory_data)
# 查看结果
print(f"Φ值:{state.phi}")
print(f"自由能:{state.free_energy}")# 运行快速示例 cd examples python quickstart.py# 运行测试 cd tests python test_basic.py# 运行完整实验 python experiments/run_all_experiments.pyNCT 提供了丰富的实验脚本,涵盖不同的应用场景:
exp_mnist_few_shot.py少样本学习实验
run_cifar10_full.py完整图像识别
run_anomaly_detection.py时序异常检测
run_cat_recognition.py实际应用场景
NCT 提供实时的 Streamlit 可视化 Dashboard,可以监控:
# 启动 Dashboard pip install streamlit plotly pandas streamlit run visualization/nct_dashboard.py