简体   繁体   English

AttributeError: 模块“hyperopt”没有属性“uniform”

[英]AttributeError: module 'hyperopt' has no attribute 'uniform'

I am trying to define a parameter space in hyperopt.我正在尝试在 hyperopt 中定义一个参数空间。 However, when I run:但是,当我运行时:

import hyperopt as hp
SPACE = {'d1': hp.uniform('d1',-1000000,-0.5),
'd2': hp.uniform('d2',0,1),
'd3': hp.uniform('d3',0,1)} 

I receive the error in the title.我收到标题中的错误。 The only thing I found online was that I should try downgrading to networkx 1.11, so in the command prompt I ran:我在网上找到的唯一一件事是我应该尝试降级到 networkx 1.11,所以在命令提示符下我运行:

pip install networkx==1.11

and it apparently worked, but still no luck with the attribute uniform.它显然有效,但属性制服仍然没有运气。

The correct way to import the hp part of the hyperopt module is导入hyperopt模块的hp部分的正确方法是

from hyperopt import hp

You have used你用过

import hyperopt as hp

Hyperopt has inbuilt module hp which has the function uniform within it Hyperopt 内置模块hp ,其中具有uniform的功能

import hyperopt.hp as hp

and then hp.uniform would work fine for you.然后hp.uniform就可以为您工作。 This works good with networkx-2.2 .这适用于networkx-2.2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM