我尝试从嵌套列表创建 Pytorch 张量,但出现这个奇怪的错误
data = pd.read_csv('TrackDataNormalized.csv')
#Get needed columns from csv
X = data.iloc[:, 0]
y = data.iloc[:, 1]
#Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
#each element in X_train is a list, which is converted to a string when read from a csv, #so we convert it back
X_train = X_train.to_numpy(X_train)
y_train = y_train.to_numpy(y_train)
X_test = X_test.to_numpy(X_test)
y_test = y_test.to_numpy(y_test)
old_train = X_train
X_train = []
for i in range(len(old_train)):
X_train.append(ast.literal_eval(old_train[i,]))
old_test = X_test
X_test = …Run Code Online (Sandbox Code Playgroud)