PytorchStream#
- class capymoa.stream.PytorchStream[source]#
Bases:
Stream
PytorchStream turns a PyTorch dataset into a datastream.
>>> from capymoa.evaluation import ClassificationEvaluator ... >>> from capymoa.datasets import get_download_dir >>> from capymoa.stream import PytorchStream >>> from torchvision import datasets >>> from torchvision.transforms import ToTensor >>> print("Using PyTorch Dataset"); pytorchDataset = datasets.FashionMNIST( ... root=get_download_dir(), ... train=True, ... download=True, ... transform=ToTensor() ... ) Using PyTorch Dataset... >>> pytorch_stream = PytorchStream(dataset=pytorchDataset) >>> pytorch_stream.get_schema() @relation PytorchDataset @attribute attrib_0 numeric @attribute attrib_1 numeric ... @attribute attrib_783 numeric @attribute class {T-shirt/top,Trouser,Pullover,Dress,Coat,Sandal,Shirt,Sneaker,Bag,'Ankle boot'} @data >>> pytorch_stream.next_instance() LabeledInstance( Schema(PytorchDataset), x=ndarray(..., 784), y_index=9, y_label='Ankle boot' )
- __init__(
- dataset: Dataset,
- target_type='categorical',
Construct PytorchStream from a PyTorch dataset.
- Parameters:
dataset – PyTorch containing tuples of x and y
enforce_regression – Force the task to be a regression task, default is False