如何使用学习参数编写自定义 MXNet 层

How to write a custom MXNet layer with learned parameters

我正在关注 http://mxnet.io/how_to/new_op.html 中的文档,了解如何通过子classing mx.operator.CustomOp 在 python 中的 MXNet 中定义新的神经网络层 class。该示例是一个没有学习参数的损失层。那么学习到的参数如何进入forwardbackward方法呢?

我想通了。学习参数的配置与 op 的任何其他输入一样。它们在 list_arguments 方法中配置。来自 docs page on writing custom symbols

Note that list arguments declares both input and parameter and we recommend ordering them as ['input1', 'input2', ... , 'weight1', 'weight2', ...]