【问题标题】:Rapids CUML Random Forest Regression Model InferenceRapids CUML 随机森林回归模型推断
【发布时间】:2020-03-18 19:45:56
【问题描述】:

我在 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 方法中指定 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)>

【问题讨论】:

    标签: python machine-learning random-forest machine-learning-model rapids


    【解决方案1】:

    此错误消息非常令人困惑。我相信它失败了,因为 training 在 float64 中,而不是在预测中。因此,如果您改为使用 float32 进行训练,这一切都应该有效。预测的优化 GPU 实现目前仅支持 float32 models。您应该能够退回到缓慢的 CPU 预测,但是这个异常阻止了它。

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

    【讨论】:

    • 非常感谢。确实如此。使用 float32 数组重新训练后问题得到解决。
    【解决方案2】:

    int64 出现同样的错误,但 float64 出现错误。因此,任何有相同问题的人都可以简单地将int64 转换为float32int32

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    • 这并不能真正回答问题。如果您有其他问题,可以点击 提问。要在此问题有新答案时收到通知,您可以follow this question。一旦你有足够的reputation,你也可以add a bounty 来引起对这个问题的更多关注。 - From Review
    • 确实如此。如果有人遇到相同的错误但由于显示错误消息而无法解决。所以我的解决方案应该可以解决这个问题。
    猜你喜欢
    • 2021-02-28
    • 2022-11-11
    • 2019-12-06
    • 2018-12-06
    • 2018-06-24
    • 2016-04-24
    • 1970-01-01
    • 2013-07-23
    • 2019-08-08
    相关资源
    最近更新 更多