How to import our own data using torch instead of pandas?

As we are using pandas to import the data till now. How can we import data using pytorch without using pd.read_csv()?

whyy not use pandas, and what do you mean by “import data using pytorch”. pytorch is just a python package.

I generally do with pandas. I am trying to explore Pytorch.

I tried this

df = torch.utils.data.DataLoader(‘train.csv’)

I am in working directory with train.csv as my data and i am trying to laod that with pytorch and i am getting an error:

TypeError: __init __() missing 1 required positional argument: ‘target_tensor’

Dataloader works with directories containing data files (for example images), in your case you just want to open a csv, so you should keep using pandas. After this you can still convert your pandas arrays into pytorch tensors.

There is comprehensive document on DataLoader… You can’t just pass in something without seeing what its inputs are and expect it to work. http://pytorch.org/docs/0.2.0/data.html#torch.utils.data.DataLoader

1 Like