Skip to content

Instantly share code, notes, and snippets.

@Mehdi-Amine
Last active June 22, 2020 16:07
Show Gist options
  • Save Mehdi-Amine/cee37506ecdcd081a16783343772c9a7 to your computer and use it in GitHub Desktop.
Save Mehdi-Amine/cee37506ecdcd081a16783343772c9a7 to your computer and use it in GitHub Desktop.
creating data loader to feed data to the network
import torch
from torch.utils.data import TensorDataset
from torch.utils.data import DataLoader
# Converting from numpy arrays to torch tensors
x_train = torch.from_numpy(train_set_std[:,:-1]).float()
y_train = torch.from_numpy(train_set_std[:,-1]).long()
# Creating tensor-datasets
train_ds = TensorDataset(x_train, y_train)
# Creating data-loaders
batch_size = 32
train_dl = DataLoader(train_ds, batch_size=batch_size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment