NCT

快速开始

5 分钟快速了解 NCT 的基本使用方法

1. 安装依赖

pip install torch numpy scipy

NCT 的核心依赖非常简单,只需要 PyTorch、NumPy 和 SciPy。建议使用 Python 3.8+ 和 PyTorch 2.0+。

2. 基本使用

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}")

3. 运行示例

# 运行快速示例 cd examples python quickstart.py
# 运行测试 cd tests python test_basic.py
# 运行完整实验 python experiments/run_all_experiments.py

4. 实验脚本

NCT 提供了丰富的实验脚本,涵盖不同的应用场景:

exp_mnist_few_shot.py

少样本学习实验

run_cifar10_full.py

完整图像识别

run_anomaly_detection.py

时序异常检测

run_cat_recognition.py

实际应用场景

5. 可视化 Dashboard

NCT 提供实时的 Streamlit 可视化 Dashboard,可以监控:

  • Φ值动态变化
  • 自由能下降曲线
  • 注意力权重热图
  • 多候选竞争过程
# 启动 Dashboard pip install streamlit plotly pandas streamlit run visualization/nct_dashboard.py

下一步

现在你已经掌握了 NCT 的基本使用方法!继续深入学习: