tensors_to_ndarrays

tensors_to_ndarrays#

ptyrad.utils.common.tensors_to_ndarrays(data)[source]#

Recursively convert all torch.Tensor instances in any nested structure (including lists, dicts, and tuples) into numpy.ndarray.

This function supports both single objects and arbitrarily nested container types. Non-tensor types are returned unchanged.

Parameters:

data – Input data which can be nested dict, list, tuple, torch.Tensor, or other.

Returns:

The same structure with torch.Tensor replaced by numpy.ndarray.