Convert inputs to tf.data.Dataset.
convert_inputs_to_tf_dataset(x=None, y=None, sample_weight=None, batch_size=None)Convert inputs to tf.data.Dataset.
TensorFlow tf.data adapters: generators, arrays and batches from other loaders.
convert_inputs_to_tf_datasetfunctionConvert inputs to tf.data.Dataset.create_interleaved_dataset_from_generatorfunctionAdapt caller-owned schedules to tf.data without changing sample weights.create_dataset_from_datafunctionHelper function to create dataset from static dataget_output_signaturefunctionGet output signature from sample outputsget_output_signature_from_fnfunctionGet output signature from a functionget_output_signature_from_genfunctionGet output signature from a generatorto_tf_datasetfunctionWrap a re-iterable of NumPy batches, such as a Grain dataset, as a tf.data.Dataset.Convert inputs to tf.data.Dataset.
convert_inputs_to_tf_dataset(x=None, y=None, sample_weight=None, batch_size=None)Convert inputs to tf.data.Dataset.
Adapt caller-owned schedules to tf.data without changing sample weights.
create_interleaved_dataset_from_generator( data_generator: Callable[[Iterator[T]], Iterable[K]], id_generator: Callable[[list[T]], Iterator[T]], ids: list[T], spec: tf.TensorSpec | tuple[tf.TensorSpec, ...] | dict[str, tf.TensorSpec], preprocess: Callable[[K], K] | None = None, num_workers: int = 4, *, stream_mode: StreamMode | str = StreamMode.GLOBAL, deterministic: bool = True,) -> tf.data.DatasetAdapt caller-owned schedules to tf.data without changing sample weights.
GLOBAL preserves one finite/repeated stream. FINITE partitions terminating, partition-independent generators; deterministic mode preserves partition order. num_workers counts generators, not processes. See https://ambiqai.github.io/helia-edge/guide/input-pipeline/.
Helper function to create dataset from static data
create_dataset_from_data(x: npt.NDArray, y: npt.NDArray, spec: tuple[tf.TensorSpec, ...]) -> tf.data.DatasetHelper function to create dataset from static data
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | npt.NDArray | Required | Numpy data |
y | npt.NDArray | Required | Numpy labels |
Returns
| Type | Description |
|---|---|
tf.data.Dataset | tf.data.Dataset: Dataset |
Get output signature from sample outputs
get_output_signature( outputs: keras.KerasTensor | npt.NDArray | tuple[keras.KerasTensor | npt.NDArray],) -> tf.TensorSpec | tuple[tf.TensorSpec, ...]Get output signature from sample outputs
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
outputs | keras.KerasTensor | npt.NDArray | tuple[keras.KerasTensor | npt.NDArray] | Required | Outputs. A tensor or tuple of tensors. Either KerasTensor, tf.Tensor, or numpy array. |
Returns
| Type | Description |
|---|---|
tf.TensorSpec | tuple[tf.TensorSpec, ...] | tf.TensorSpec: Tensor spec |
Get output signature from a function
get_output_signature_from_fn( fn: Callable[..., keras.KerasTensor], *args=(),) -> tf.TensorSpec | tuple[tf.TensorSpec, ...]Get output signature from a function
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
fn | Callable[..., tf.Tensor] | Required | Function |
Returns
| Type | Description |
|---|---|
tf.TensorSpec | tuple[tf.TensorSpec, ...] | tf.TensorSpec: Tensor spec |
Get output signature from a generator
get_output_signature_from_gen( gen: Callable[..., Iterator[Any]], *args: Any = (),) -> tf.TensorSpec | tuple[tf.TensorSpec, ...]Get output signature from a generator
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
gen | Callable[..., Iterator[Any]] | Required | Generator factory |
Returns
| Type | Description |
|---|---|
tf.TensorSpec | tuple[tf.TensorSpec, ...] | tf.TensorSpec: Tensor spec |
Wrap a re-iterable of NumPy batches, such as a Grain dataset, as a tf.data.Dataset.
to_tf_dataset(dataset: Iterable[Any], output_signature: tf.TensorSpec | tuple | dict[str, Any]) -> tf.data.DatasetWrap a re-iterable of NumPy batches, such as a Grain dataset, as a tf.data.Dataset.
Elements pass through in order, one iter(dataset) per pass of the returned dataset;
nothing is batched, shuffled or read in parallel here. Do that in dataset.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
dataset | Iterable[Any] | Required | Re-iterable whose ``iter()`` starts from the first element. |
output_signature | tf.TensorSpec | tuple | dict[str, Any] | Required | ``tf.TensorSpec`` structure matching one element. Use ``None`` for a batch dimension that varies, such as a smaller last batch. |
Returns
| Type | Description |
|---|---|
tf.data.Dataset | tf.data.Dataset: Built with ``tf.data.Dataset.from_generator``. |
Raises
| Type | Description |
|---|---|
ImportError | If TensorFlow is not installed (``helia-edge[tensorflow]``). |