Despite deep learning models running well-defined mathematical functions, we lack a formal mathematical framework for describing model architectures. Ad-hoc notation, diagrams, and pseudocode poorly handle nonlinear broadcasting and the relationship between individual components and composed models. This paper introduces a categorical framework for deep learning models that formalizes broadcasting through the novel axis-stride and array-broadcasted categories. This allows the mathematical function underlying architectures to be precisely expressed and manipulated in a compositional manner. These mathematical definitions are translated into human manageable diagrams and machine manageable data structures. We provide a mirrored implementation in Python (pyncd) and TypeScript (tsncd) to show the universal aspect of our framework, along with features including algebraic construction, graph conversion, PyTorch compilation and diagram rendering. This lays the foundation for a systematic, formal approach to deep learning model design and analysis.
翻译:尽管深度学习模型运行着定义明确的数学函数,但我们仍缺乏描述模型架构的形式化数学框架。临时性的符号、示意图和伪代码难以妥善处理非线性广播以及单个组件与组合模型之间的关系。本文引入了一个面向深度学习模型的范畴论框架,通过新颖的轴步幅范畴和数组广播范畴对广播操作进行形式化。这使得架构背后的数学函数能够以组合方式被精确表达和操控。这些数学定义被转化为人类可理解的示意图和机器可管理的数据结构。我们提供了Python (pyncd) 和TypeScript (tsncd) 中的镜像实现,以展示框架的普适性,附带功能包括代数构建、图转换、PyTorch编译和图表渲染。这为深度学习模型设计与分析的系统化形式化方法奠定了基础。