The methods from np.ndarray to torch.tensor may be changed, so I use another method to convert np.ndarray to torch.tensor.
train_features = torch.from_numpy(all_features[:n_train].values.astype(float))
test_features = torch.from_numpy(all_features[n_train:].values.astype(float))
train_labels = torch.from_numpy(self.train_data.SalePrice.values.reshape(-1, 1)).to(dtype=torch.float32)