mrkn / mxnet.rb

MXNet binding for Ruby
MIT License
48 stars 10 forks source link

How to code 2 fixed position arguments method #22

Closed ljulliar closed 6 years ago

ljulliar commented 6 years ago

Hi,

I'm currently trying to implement NDArray.zeros_like (see https://mxnet.incubator.apache.org/api/python/ndarray/ndarray.html#mxnet.ndarray.NDArray.zeros_like )

I tried writing something like

    def self.ones_like(lhs, rhs, *args, **kwargs)
      Ops.zeros_like(lhs, rhs, *args, **kwargs)
    end

But then I get the following error when trying to call the method:

 2) MXNet::NDArray.zeros_like 
     Failure/Error: def #{op_info.func_name}(#{signature.join(', ')})

     ArgumentError:
       wrong number of arguments (given 2, expected 0..1)
     # ./lib/mxnet/ndarray/operation_delegator.rb:66:in `zeros_like'
     # ./spec/mxnet/ndarray_spec.rb:340:in `block (3 levels) in <module:MXNet>'

It looks like operation delegation only works form method with one fixed position argument whereas zeros_like has two. How to work around that ?

Thank you.

mrkn commented 6 years ago

@ljulliar The number of positional argument of zeros_like is 1, but not 2.

ljulliar commented 6 years ago

Sorry for that. It was a stupid question. I didn't even look at the documentation and wrongly assumed that zeros_like and ones_like had the same logic as reshape_like.