Search code examples
pythondeep-learningmxnet

Mxnet - Understanding weight shape for Dense Layer


I am understanding Mxnet framework. While following this Linear Regression article I see the following piece of code which is creating a Dense Layer:

net = gluon.nn.Dense(1, in_units=2) # input dimension= 2, output dimension = 1

but why does print(net.weight) give shape as Parameter dense4_weight (shape=(1, 2), dtype=None)

Shouldn't the shape be (2, 1)?

According to my understanding:

input = Shape(n, 2) where n is number of samples
output = Shape(n, 1)

so the weight matrix should be Shape(2, 1) for the matrix multiplication, isn't it?

What am I missing here?


Solution

  • This is just due to internal implementation. You can think of it as weight matrix is transposed before multiplication.