Closed tk4218 closed 4 years ago
MXNDArrayCreateEx let you pass dtype to define the type of data. Looking into the issue.
On Fri, Jul 3, 2020 at 7:34 AM tk4218 notifications@github.com wrote:
I am trying to create an NDArray by using nd.Array(), however if I pass in Int32 values for the array, it is giving me unexpected results.
For example, if I create: var ndArray = nd.Array(new int[] {0, 0, 15, 15})
It creates the NDArray with DType = float32, when I am expecting DType = int32 The underlying ArrayData for the object becomes {0, 0, 2.101948E-44, 2.101948E-44}, when it should be {0, 0, 15, 15}
Additionally, calling nd.Array() and passing in the array as a NumpyDotNet NDArray also creates unexpected results. In this case, it appears to be creating the NDArray as it does in the first scenario, then casting to int32, which results in ArrayData being {0, 0, 0, 0}
I believe if nd.Array() used NativeMethods.MXNDArrayCreateEx() instead of NativeMethods.MXNDArrayCreate(), the DType could be determined from the passed in array and passed to the function to set the NDArray properly.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tech-quantum/MxNet.Sharp/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQJAKOPM5OCLFUITLTKFITRZT75ZANCNFSM4OPI2KBQ .
-- Regards, Deepak
Fixed and nuget updated. Please check
On Fri, Jul 3, 2020 at 9:40 AM Deepak Battini deepakkumar1984@gmail.com wrote:
MXNDArrayCreateEx let you pass dtype to define the type of data. Looking into the issue.
On Fri, Jul 3, 2020 at 7:34 AM tk4218 notifications@github.com wrote:
I am trying to create an NDArray by using nd.Array(), however if I pass in Int32 values for the array, it is giving me unexpected results.
For example, if I create: var ndArray = nd.Array(new int[] {0, 0, 15, 15})
It creates the NDArray with DType = float32, when I am expecting DType = int32 The underlying ArrayData for the object becomes {0, 0, 2.101948E-44, 2.101948E-44}, when it should be {0, 0, 15, 15}
Additionally, calling nd.Array() and passing in the array as a NumpyDotNet NDArray also creates unexpected results. In this case, it appears to be creating the NDArray as it does in the first scenario, then casting to int32, which results in ArrayData being {0, 0, 0, 0}
I believe if nd.Array() used NativeMethods.MXNDArrayCreateEx() instead of NativeMethods.MXNDArrayCreate(), the DType could be determined from the passed in array and passed to the function to set the NDArray properly.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tech-quantum/MxNet.Sharp/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQJAKOPM5OCLFUITLTKFITRZT75ZANCNFSM4OPI2KBQ .
-- Regards, Deepak
-- Regards, Deepak
I am trying to create an
NDArray
by usingnd.Array()
, however if I pass in Int32 values for the array, it is giving me unexpected results.For example, if I create:
var ndArray = nd.Array(new int[] {0, 0, 15, 15})
It creates the
NDArray
withDType = float32
, when I am expectingDType = int32
The underlyingArrayData
for the object becomes{0, 0, 2.101948E-44, 2.101948E-44}
, when it should be{0, 0, 15, 15}
Additionally, calling
nd.Array()
and passing in the array as aNumpyDotNet NDArray
also creates unexpected results. In this case, it appears to be creating theNDArray
as it does in the first scenario, then casting toint32
, which results inArrayData
being{0, 0, 0, 0}
I believe if
nd.Array()
usedNativeMethods.MXNDArrayCreateEx()
instead ofNativeMethods.MXNDArrayCreate()
, theDType
could be determined from the passed in array and passed to the function to set theNDArray
properly.