Skip to content

how could I transform between NumSharp.NDArray with Tensorflow.Numpy.NDArray? #465

Closed

Description

@cross-hello

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~

Activity

  1. Oceania2018 commented on Nov 27, 2021

    @Oceania2018
    Member

    What are the missing methods?

  2. Nucs commented on Sep 7, 2026

    @Nucs
    Member

    @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:

    var a = np.array(new[] { 1.0, 2, 3 });
    byte[] raw = a.tobytes();
    
    var back = 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.

    Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions