Skip to content

When I run this program I have a error like this please help me with this issue. #1

@vinoth654321

Description

@vinoth654321
import torch
a = torch.cuda.is_available()
b = torch.cuda.current_device()
c = torch.cuda.get_device_name()
d = torch.cuda.memory_reserved()
e = torch.cuda.memory_allocated()
var1 = torch.FloatTensor([1.0,2.0,3.0]).cuda()
var1
a1 = var1.device
import pandas as pd
df = pd.read_csv('diabetes.csv')
df.head()
b1 = df.isnull().sum()
import seaborn as sns
import numpy as np
df['Outcome']=np.where(df['Outcome']==1,"Diabetic","No Diabetic")
b2 = df.head()
b3 = sns.pairplot(df,hue="Outcome")

X=df.drop('Outcome',axis=1).values
y=df['Outcome'].values

from sklearn.model_selection import train_test_split

X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=0)
y_train

import torch
import torch.nn as nn
import torch.nn.functional as F

X_train=torch.FloatTensor(X_train).cuda()
X_test=torch.FloatTensor(X_test).cuda()
z=y_train=torch.FloatTensor(y_train).cuda()
print(z)
This is the error I got:

C:\Users\vinot\.conda\envs\python21\python.exe D:/python/python_work/pythonProject/diabetes.py
Traceback (most recent call last):
  File "D:/python/python_work/pythonProject/diabetes.py", line 34, in <module>
    z=y_train=torch.FloatTensor(y_train).cuda()
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions