NumSharp icon indicating copy to clipboard operation
NumSharp copied to clipboard

how to make NumSharp.NDArray from Numpy.NDarray?

Open djagatiya opened this issue 5 years ago • 1 comments

djagatiya avatar Jul 06 '20 13:07 djagatiya

I found a solution, but is this the right way to do it?

Numpy.NDarray numpyArray = Numpy.np.random.randn(224,224,3);
byte[] v = numpyArray.GetData<byte>();
fixed (byte* packet = v)
{
    var block = new UnmanagedMemoryBlock<byte>(packet, v.Length);
    var storage = new UnmanagedStorage(new ArraySlice<byte>(block), numpyArray.shape.Dimensions);
    NumSharp.NDArray numSharpArray = new NumSharp.NDArray(storage);
}

djagatiya avatar Jul 07 '20 05:07 djagatiya