急流 CUML 随机森林回归模型推理



我在Google Colab上使用CUML 0.10.0库中的随机森林回归模型,但在获取模型预测时遇到问题。模型训练成功结束后,我正在使用 (.predict( 方法对非常大的数组进行推理 (41697600, 11(。但是,我收到以下错误:

TypeError: GPU predict model only accepts float32 dtype as input, convert the data to float32 or use the CPU predict with `predict_model='CPU'`.

即使在将输入 numpy 数组的 dtype 转换为 float32 并在预测方法中指定 predict_model='CPU' 参数后,错误仍然存在。

这是用于供您参考的代码:

array=(X_test.values).astype('float32')
predictions = cuml_model.predict(array, predict_model='CPU',output_class=False, algo='BATCH_TREE_REORG')

模型摘要:

<bound method RandomForestRegressor.print_summary of RandomForestRegressor(n_estimators=10, max_depth=16, handle=<cuml.common.handle.Handle object at 0x7fbfa342e888>, max_features='auto', n_bins=8, n_streams=8, split_algo=1, split_criterion=2, bootstrap=True, bootstrap_features=False, verbose=False, min_rows_per_node=2, rows_sample=1.0, max_leaves=-1, accuracy_metric='mse', quantile_per_tree=False, seed=-1)>

此错误消息非常令人困惑。我相信它失败了,因为训练是在 float64 而不是预测中。因此,如果您在 float32 中进行训练,这应该都可以工作。预测的优化 GPU 实现目前仅支持 float32模型。您应该能够回退到慢速 CPU 预测,但此异常会阻止它。

我将其作为错误提交,我们将尝试为即将发布的版本进行修复。请随时关注那里或添加任何额外的问题等:https://github.com/rapidsai/cuml/issues/1406

我遇到了同样的错误int64但错误显示float64.因此,任何有相同问题的人都可以简单地将int64转换为float32int32.

最新更新