How to initialize weights of Conv2D layer given an NDarray?

let’s say I have the following code:

from mxnet import gluon
from mxnet import nd

weights = ... # NDArray of shape (32, 7, 7)
myLayer = gluon.nn.Conv2D(32, (7,7))

What’s the easiest way to initialize the weights of myLayer using weights?


you can do myLayer.collect_params.initialize as usual with the Constant Initializer. See

For example: