The Java and Scala community has built a very successful big data ecosystem. However, most of neural networks running on it are modeled in dynamically typed programming languages. These dynamically typed deep learning frameworks treat neural networks as differentiable expressions that contain many trainable variable, and perform automatic differentiation on those expressions when training them. Until 2019, none of the learning frameworks in statically typed languages provided the expressive power of traditional frameworks. Their users are not able to use custom algorithms unless creating plenty of boilerplate code for hard-coded back-propagation. We solved this problem in DeepLearning.scala 2. Our contributions are: 1. We discovered a novel approach to perform automatic differentiation in reverse mode for statically typed functions that contain multiple trainable variable, and can interoperate freely with the metalanguage. 2. We designed a set of monads and monad transformers, which allow users to create monadic expressions that represent dynamic neural networks. 3. Along with these monads, we provide some applicative functors, to perform multiple calculations in parallel. With these features, users of DeepLearning.scala were able to create complex neural networks in an intuitive and concise way, and still maintain type safety.
翻译:Java和Scala社区已构建了非常成功的大数据生态系统。然而,在该生态系统中运行的大多数神经网络都是使用动态类型编程语言建模的。这些动态类型深度学习框架将神经网络视为包含众多可训练变量的可微表达式,并在训练过程中对这些表达式执行自动微分。直到2019年,静态类型语言中的学习框架均未能提供传统框架的表现力,其用户若要使用自定义算法,就必须为硬编码的反向传播编写大量样板代码。我们在DeepLearning.scala 2中解决了这一问题。我们的贡献包括:1. 发现了一种新型方法,能够对包含多个可训练变量且可与元语言自由互操作的静态类型函数执行反向模式自动微分;2. 设计了一组单子(monad)和单子变换器(monad transformer),使用户能够构建表示动态神经网络的单子表达式;3. 配合这些单子,我们提供了若干应用函子(applicative functor),用于并行执行多重计算。借助这些特性,DeepLearning.scala 2的用户能够以直观简洁的方式创建复杂神经网络,同时保持类型安全性。