Convert Pandas dataframe to PyTorch tensor?
https://www.py4u.net/discuss/159088Issue 1: leaking target info to features. Your features (df) also contains the target variable (df['Target']) i.e. your network is 'cheating', since it can see the targets in the input.You need to remove this column from the set of features. Issue 2: passing a pd.DataFrame to a PyTorch DataLoader. You can pass the values of a Pandas Dataframe (a numpy array) to the Dataset …
Convert Pandas dataframe to PyTorch tensor?
www.py4u.net › discuss › 159088Answer #3: You can use below functions to convert any dataframe or pandas series to a pytorch tensor. import pandas as pd import torch # determine the supported device def get_device(): if torch.cuda.is_available (): device = torch.device ('cuda:0') else: device = torch.device ('cpu') # don't have GPU return device # convert a df to tensor to ...