Loading...
Create a TensorDataset from feature and label tensors.
TensorDataset wraps tensors so they can be used with PyTorch's data loading utilities, pairing features with their corresponding labels automatically.
Write a function create_dataset(features, labels) that creates a TensorDataset and returns the number of samples it contains.
Return a single integer.
features=torch.tensor([[1.0, 2.0], [3.0, 4.0]]), labels=torch.tensor([0, 1])
TensorDataset with 2 samples
We use TensorDataset to wrap the feature and label tensors together