ray.data.from_numpy_refs#
- ray.data.from_numpy_refs(ndarrays: ObjectRef[numpy.ndarray] | List[ObjectRef[numpy.ndarray]]) MaterializedDataset[source]#
Creates a
Datasetfrom a list of Ray object references to NumPy ndarrays.The column name defaults to “data”.
Examples
>>> import numpy as np >>> import ray >>> arr_ref = ray.put(np.array([1])) >>> ray.data.from_numpy_refs(arr_ref) shape: (1, 1) ╭───────╮ │ data │ │ --- │ │ int64 │ ╞═══════╡ │ 1 │ ╰───────╯ (Showing 1 of 1 rows)
Create a Ray Dataset from a list of NumPy array references.
>>> ray.data.from_numpy_refs([arr_ref, arr_ref]) shape: (2, 1) ╭───────╮ │ data │ │ --- │ │ int64 │ ╞═══════╡ │ 1 │ │ 1 │ ╰───────╯ (Showing 2 of 2 rows)
- Parameters:
ndarrays – A Ray object reference to a NumPy ndarray or a list of Ray object references to NumPy ndarrays.
- Returns:
Datasetholding data from the given ndarrays.
DeveloperAPI: This API may change across minor Ray releases.