Category : dataloader

I want to build a sentiment classifier using pytorch and bert. My df dataframe has 2 columns: df[‘text’] and df[‘sentiment’], with df[‘sentiment’] being 0 for negative, 1 for neutral and 2 for positive, and df[‘text’] is plain text. The dataset is hugely imbalanced, so I want to use WeightedRandomSampler in order to balance it. However, ..

Read more

I am trying to implement a model whose output is the same as its input. It’s a simple part of an extensive model, I deleted complicated parts. I wrote a generator dataloader for generating random numbers. def random_generator(): tf.random.set_seed(43) while True: yield tf.random.uniform((3,), 0, 1, dtype=tf.dtypes.float32, seed=32) random_dataset = tf.data.Dataset.from_generator( random_generator, output_types=tf.float32, output_shapes=(3,) ) I ..

Read more

I have encountered this error in the process of classifying and learning crime datasets, and performing num_workers = 0 from multiple communities results in occur NoneType’ object is not subscriptable. I don’t know where the problem is. pytorch version = 1.9.0, python = 3.8 The dataset uses UCF-crime. this my error code Empty Traceback (most ..

Read more

My CNN model is working perfectly without data augmentation, I need to add data augmentation using transformers in the CNN model but got the error below: val_dataset = dataset(self.num, self.transform, is_train=False) TypeError: init() should return None, not ‘int’ Since I just changed the dataset with adding transform I am wondering why data types have changed ..

Read more

I am following some tutorials online about Pytorch and it seems at some point I do not get the expected output although I follow everything step by step. import torch import torchvision from torchvision import datasets, transforms Train = datasets.MNIST("", train=True, download=True, transform=transforms.Compose([transforms.ToTensor()])) Test = datasets.MNIST("", train=False, download=True, transform=transforms.Compose([transforms.ToTensor()])) trainset = torch.utils.data.DataLoader(Train, batch_size= 10, shuffle=True) ..

Read more