报错:
TypeErrorTraceback (most recent call last)
Cell In[165], line 2 1n_train =train_data.shape[0]
----> 2train_features =torch.tensor(all_features[:n_train].values, dtype=torch.float32) 3test_features =torch.tensor(all_features[n_train:].values, dtype=torch.float32)
4train_labels =torch.tensor(train_data.SalePrice.values.reshape(-1,1), dtype=torch.float32)
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.
解决方案:改为values.astype(np.float32)