当前位置: 首页 > article >正文

RecBole:AttributeError: module ‘ray.tune’ has no attribute ‘report’

        在执行 RecBole run_hyper.py 时,遇到 AttributeError: module ‘ray.tune’ has no attribute ‘report’,记录解决方法。

目录

1. Ray

1.1 介绍

1.2 安装

1.2.1 机器学习应用程序

1.2.2 一般 Python 应用程序

2. 问题与解决

2.1 问题

2.2 解决


1. Ray

1.1 介绍

        引用 Ray 官方介绍。

Ray is an open-source unified framework for scaling AI and Python applications like machine learning. It provides the compute layer for parallel processing so that you don’t need to be a distributed systems expert.

Ray 是一个开源统一框架,用于扩展 AI Python 应用程序(如机器学习)。它提供了用于并行处理的计算层,因此您无需成为分布式系统专家。

1.2 安装

1.2.1 机器学习应用程序
pip install -U "ray[data,train,tune,serve]"

# For reinforcement learning support, install RLlib instead.
# pip install -U "ray[rllib]"
1.2.2 一般 Python 应用程序
pip install -U "ray[default]"

# If you don't want Ray Dashboard or Cluster Launcher, install Ray with minimal dependencies instead.
# pip install -U "ray"

2. 问题与解决

2.1 问题

        问题出现在 recbole.quick_start.quick_start.objective_function 方法中的 tune.report(**test_result)

        错误提示为:

AttributeError: module ‘ray.tune’ has no attribute ‘report’

2.2 解决

        Ray 官方文档给出了新的接口 API。

        解决方案是先 from ray import train,然后通过 train.report(metrics: Dict, *, checkpoint: Checkpoint | None = None) → None 来执行。即更改为:

from ray import train


def objective_function(config_dict=None, config_file_list=None, saved=True):
...more code
    test_result = trainer.evaluate(test_data, load_best_model=saved)

    train.report(**test_result)
...more code

        注意,这里 report 方法接收 Dict 参数,**test_result** 表示解析字典。


http://www.kler.cn/news/340888.html

相关文章:

  • Ansible 中的 Role
  • PyTorch搭建GNN(GCN、GraphSAGE和GAT)实现多节点、单节点内多变量输入多变量输出时空预测
  • 快速生成单元测试
  • 常用的devops工具集成方法
  • C# 基于winform 使用NI-VISA USB口远程控制电源 万用表
  • vue中的keep-alive用过吗?什么是keep-alive?
  • Python 工具库每日推荐【Pillow】
  • 开源的键鼠共享工具「GitHub 热点速览」
  • 网络安全-Wireshark抓包的TCP三次握手
  • Ubuntu下Typora的安装与配置激活
  • 数据结构前置知识(上)
  • C/C++解析文件名和目录路径
  • K8s(学习笔记)
  • 【Oracle APEX开发小技巧9】通过页面设置文本大写避免upper()函数转换占用额外资源
  • 息肉检测数据集 yolov5 yolov8适用于目标检测训练已经调整为yolo格式可直接训练yolo网络
  • Axios 和 Ajax 的区别与联系
  • 【React】setState (useState) 是怎么记住上一个状态值的?
  • (1)Matlab画常见普通柱状图
  • 使用YOLOv11进行视频目标检测
  • Leetcode 18. 四数之和