将 PyTorch 张量与 scikit-learn 结合使用
Using PyTorch tensors with scikit-learn
我可以在使用 scikit-learn 时使用 PyTorch 张量而不是 NumPy 数组吗?
我尝试了一些来自 scikit-learn 的方法,比如 train_test_split
和 StandardScalar
,它似乎工作得很好,但是当我使用 PyTorch 张量而不是NumPy 数组?
numpy arrays or scipy sparse matrices. Other types that are convertible to numeric arrays such as pandas DataFrame are also acceptable.
这是否意味着使用 PyTorch 张量是完全安全的?
我认为 scikit-learn 不直接支持 PyTorch 张量。但是你总是可以从 PyTorch 张量中获取底层的 numpy 数组
my_nparray = my_tensor.numpy()
然后将其与 scikit 学习功能一起使用。
我可以在使用 scikit-learn 时使用 PyTorch 张量而不是 NumPy 数组吗?
我尝试了一些来自 scikit-learn 的方法,比如 train_test_split
和 StandardScalar
,它似乎工作得很好,但是当我使用 PyTorch 张量而不是NumPy 数组?
numpy arrays or scipy sparse matrices. Other types that are convertible to numeric arrays such as pandas DataFrame are also acceptable.
这是否意味着使用 PyTorch 张量是完全安全的?
我认为 scikit-learn 不直接支持 PyTorch 张量。但是你总是可以从 PyTorch 张量中获取底层的 numpy 数组
my_nparray = my_tensor.numpy()
然后将其与 scikit 学习功能一起使用。