Setting dataset feature value as numpy array

lhoestq
Thu, 28 Jul 2022 09:56:47 +0000

Hi ! You can use datasets.Sequence(datasets.Value("float32")). Since a dataset is simply a wrapper around an Arrow table, your numpy array will be converted to Arrow format anyway.

Though you can still set the format of the dataset to “np” to output numpy arrays

ds = ds.with_format("np")