1

I'm using the CustomOp class in MXNet to create a new transformation layer. This layer has output_dimensionality as a hyper-parameter for the layer. This dimensionality can't automatically be inferred from the data, but needs to be chosen by the caller who is building the network graph, so it should be a constructor argument for the new symbol, like

net = mx.symbol.Custom(data=data, op_type='mycustomop', output_dimensionality=1024)

which would be consumed by the __init__ constructor of my CustomOp subclass. But when I try this, I get:

Traceback (most recent call last): File "_ctypes/callbacks.c", line 314, in 'calling callback function' File "python/mxnet/operator.py", line 602, in creator op_prop = prop_cls(**kwargs) TypeError: __init__() got an unexpected keyword argument 'output_dimensionality' Segmentation fault (core dumped)

Leopd
  • 41,333
  • 31
  • 129
  • 167

1 Answers1

0

This shouldn't be a problem, but you would need to specify your parameter in both CustomOp class and CustomOpProps class.

Here is the example how to do that. There are 2 custom parameters passed to init: pos_grad_scale and neg_grad_scale and they are accepted in both CustomOp and CustomOpProps.

Also notice that there is a conversion to float via float() function. This is done because parameters like that are always passed as strings (even if it is an array), so you would need to convert your integer back from string.

Sergei
  • 1,617
  • 15
  • 31