zero.data.FnDataset.__init__

FnDataset.__init__(fn, args, transform=None)[source]

Initialize self.

Parameters
  • fn (Callable[[..], T]) – the function that produces values based on arguments from args

  • args (Union[int, Iterable]) – arguments for fn. If an iterable, but not a list, then is casted to a list. If an integer, then the behavior is the same as for list(range(args)). The size of args defines the return value for FnDataset.__len__.

  • transform (Optional[Callable[[T], Any]]) – if presented, is applied to the return value of fn in FnDataset.__getitem__

Return type

None

Examples

import PIL.Image as Image
import torchvision.transforms as T

dataset = FnDataset(Image.open, filenames, T.ToTensor())