You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
cuml PCA .transform() requires n_rows > 1 which is surprising as sklearn PCA doesn't have the same requirement.
I caught this trying to make predictions using a previously saved model that included a pipeline with a cuml PCA model. In my case, predictions are over a single example. My workaround will be to tile the example but it feels like this should not be necessary.
Traceback (most recent call last):
File "test3.py", line 9, in <module>
y = model.transform(predict)
File "/home/ngs/miniconda3/envs/cuml14/lib/python3.7/site-packages/cuml/common/memory_utils.py", line 56, in cupy_rmm_wrapper
return func(*args, **kwargs)
File "cuml/decomposition/pca.pyx", line 716, in cuml.decomposition.pca.PCA.transform
RuntimeError: Exception occured! file=/opt/conda/envs/rapids/conda-bld/libcuml_1598033241212/work/cpp/src/pca/pca.cuh line=230: Parameter n_rows: number of rows cannot be less than two
Steps/Code to reproduce bug
This code throws the exception using cuml PCA but works fine using sklearn PCA:
importnumpyasnp# from sklearn.decomposition import PCAfromcuml.decompositionimportPCAtrain=np.asfortranarray(np.random.randn(10,10))
predict=np.asfortranarray(np.random.randn(1,10))
model=PCA(n_components=4)
model.fit(train)
y=model.transform(predict)
Expected behavior
I expected cuml PCA transform() to be able to transform a single example.
Whoops, submitted that comment before I was done. Adding on... I don't immediately see why this assertion would be necessary except if the whiten option is true. In the case of n_rows == 1, whitening obviously does not make sense, so we can probably add some special handling there.
Describe the bug
cuml PCA .transform() requires n_rows > 1 which is surprising as sklearn PCA doesn't have the same requirement.
I caught this trying to make predictions using a previously saved model that included a pipeline with a cuml PCA model. In my case, predictions are over a single example. My workaround will be to tile the example but it feels like this should not be necessary.
Steps/Code to reproduce bug
This code throws the exception using cuml PCA but works fine using sklearn PCA:
Expected behavior
I expected cuml PCA transform() to be able to transform a single example.
Environment details:
Click here to see environment details
The text was updated successfully, but these errors were encountered: