Manipulate Parameters directly?

I am using gluon now.
for a brief example, AntisymmetricRNN
That network seems difficult for me to reproduce, mxnet has no “Antisymmetric matrix” now, but I found it is much easier to get an antisymmetric weight matrix by:

x=[i for i in net.collect('the weight I want').values()][0]

the x._data[0] could be what I want.
BUT… the question is, I cannot using x._data[0]=... since gluon.Trainer will raise an exception.
My solution is using x._data[0]+=... or something else, much ugly than what I expected.
Is there any good solutions to manipulate parameters directly?
Thanks:)

Hi @Neutron,

You might find param.data() and param.set_data() useful for getting and setting parameters. Can you clarify what the additional requirements are for an antisymmetric matrix? Can this not just be stored as an NDArray?

I think it is easy to store an antisymmetric matrix into a NDArray.

a=mx.nd.random.uniform(0,1,(5,5))# we got a matrix
a-=a.swapaxes(0,1)
a/=2#a is an antisymmetric matrix now.
....
# if `a` will be updated
a._grad-=a._grad.swapaxes(0,1)
a._grad/=2
trainer.step(...)

Fine.
#BTW, param.set_data() is a good way to manipulate parameters. it won’t bother trainer