Convert Pandas dataframe to PyTorch tensor?
https://www.py4u.net/discuss/159088import 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 be used in pytorch def df_to_tensor (df): device = get_device() return torch.from_numpy(df.values). float ().to(device) df_tensor = …