You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Autogluon.core无space属性报错:设置模型超参数遇AttributeError

解决Autogluon中ag.space的AttributeError问题

问题原因

Autogluon版本迭代后调整了模块结构,space不再是autogluon.core的直接属性,而是作为独立子模块存在,直接通过ag.space调用会触发属性不存在的报错。

修复方案

修改导入语句并替换代码中对应的ag.space引用,以下是两种可行的修改方式:

方式1:导入space子模块

import autogluon.core as ag
from autogluon.core import space

nn_options = {
    'num_epochs': 10,  
    'learning_rate': space.Real(1e-4, 1e-2, default=5e-4, log=True),  
    'activation': space.Categorical('relu', 'softrelu', 'tanh'),  
    'dropout_prob': space.Real(0.0, 0.5, default=0.1),  
}

gbm_options = { 
    'num_boost_round': 100,  
    'num_leaves': space.Int(lower=26, upper=66, default=36),  
} 

方式2:直接导入所需空间类

from autogluon.core.space import Real, Categorical, Int

nn_options = {
    'num_epochs': 10,  
    'learning_rate': Real(1e-4, 1e-2, default=5e-4, log=True),  
    'activation': Categorical('relu', 'softrelu', 'tanh'),  
    'dropout_prob': Real(0.0, 0.5, default=0.1),  
}

gbm_options = { 
    'num_boost_round': 100,  
    'num_leaves': Int(lower=26, upper=66, default=36),  
} 

内容的提问来源于stack exchange,提问作者Zubair Maalick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 16:32:49