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, ..
I want to combine k fold cross-validation and data loader, but I don’t know how to do the data augmentation, because if I use k fold cross-validation, the train set and the validation set will be changed all the time, and in this case, their augmentation will be the same, but usually, there is no ..
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 ..
I want to iterate over a custom DataLoader using batches with matching values and labels. Modification of PandasDataset described below is needed and since I copied it from online I do not have a great grasp of how it works import torch import pandas as pd from torch.utils.data import Dataset from torch.utils.data import DataLoader class ..
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 ..
I’m trying to create a custom pytorch dataset to plug into DataLoader that is composed of single-channel images (20000 x 1 x 28 x 28), single-channel masks (20000 x 1 x 28 x 28), and three labels (20000 X 3). Following the documentation, I thought I would test creating a dataset with a single-channel image ..
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 ..
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) ..
I’m working on a sentiment analysis using IMDB dataset. I’ve imported .csv, done text normalisation and done test, traind valid split. Now I’m using a code for data loader but I’m getting an error which I didn’t get before. Please have in mind that this code worked 1 year ago when I found in on ..
Please, could you help me to find the solution to my problem. I want to write collate_fn to make my pictures the equal size, but I don’t know how to implement it correctly. Colab: link Code: import pandas as pd import numpy as np from PIL import Image from torchvision import transforms from torch.utils.data.dataset import ..