You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
how could I transform between NumSharp.NDArray with Tensorflow.Numpy.NDArray? #465
Both library complement the functionality of Numpy library. There are some lack for methods between. So I want to know the converting method.
Give me a hand~
@cross-hello, there's no direct type converter between the two libraries, but both wrap raw buffers, so you can bridge in two ways (0.70.0, #628):
1. Via the byte buffer - tobytes out, np.frombuffer in:
vara=np.array(new[]{1.0,2,3});byte[]raw=a.tobytes();varback=np.frombuffer(raw,"float64");// [1. 2. 3.]// hand `raw` to Tensorflow.NumPy the same way, or read its buffer back through frombuffer
2. Via NumSharp.Interop.pythonnet - cross through a real numpy array (arr.ToNumpy() / pyObj.AsNDArray()), which any numpy-based stack accepts.
Activity
Oceania2018 commentedon Nov 27, 2021
What are the missing methods?
Nucs commentedon Sep 7, 2026
@cross-hello, there's no direct type converter between the two libraries, but both wrap raw buffers, so you can bridge in two ways (0.70.0, #628):
1. Via the byte buffer -
tobytesout,np.frombufferin:2. Via
NumSharp.Interop.pythonnet- cross through a real numpy array (arr.ToNumpy()/pyObj.AsNDArray()), which any numpy-based stack accepts.Closing.