自动深度学习auto-pytorch安装
创始人
2024-04-30 00:43:58
0

安装

实测window安装不了,自己捣鼓了半天终于要成功时,报了个错

ImportError: No module named resource

pip安装也没解决,最后百度说是resource模块在windows上是不可用的
所以只能放弃

Mac 安装auto-pytorch

pip install swig
pip install pyrfr
pip install autoPyTorch

正常情况下就能安装好了

过程常见报错

1、lightgbm依赖

第一次使用报错:

OSError: dlopen(/Users/*/opt/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so, 0x0006): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
Referenced from: /Users/
/opt/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so
Reason: tried: ‘/usr/local/opt/libomp/lib/libomp.dylib’ (no such file), ‘/usr/local/lib/libomp.dylib’ (no such file), ‘/usr/lib/libomp.dylib’ (no such file)

使用autoPyTorch需要安装lightgbm
解决方案:

pip uninstall lightgbm
conda install lightgbm

2、brew安装

bash: brew: command not found…

解决方案:
终端直接输入:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

过程中,国内景象选择清华大学,差不多十几分钟就好了

3、brew install报错

fatal: not in a git directory Error: Command failed with exit 128: git

先输入:brew -v
会提示相应的方法:

(base) MacBook-Pro:~ ***$ brew -v
Homebrew 3.6.16-8-g895d322
fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'
To add an exception for this directory, call:git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core (no Git repository)
fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'
To add an exception for this directory, call:git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)

将上面提示的两段代码输入终端运行即可:

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core 
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask 

实战

我们先使用官网案例验证下:

import os
import tempfile as tmp
import warningsfrom autoPyTorch.datasets.resampling_strategy import CrossValTypesos.environ['JOBLIB_TEMP_FOLDER'] = tmp.gettempdir()
os.environ['OMP_NUM_THREADS'] = '1'
os.environ['OPENBLAS_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'warnings.simplefilter(action='ignore', category=UserWarning)
warnings.simplefilter(action='ignore', category=FutureWarning)import sklearn.datasets
import sklearn.model_selection

from autoPyTorch.api.tabular_classification import TabularClassificationTaskX, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True)
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(X,y,random_state=1,
)api = TabularClassificationTask(# To maintain logs of the run, you can uncomment the# Following lines# temporary_directory='./tmp/autoPyTorch_example_tmp_01',# output_directory='./tmp/autoPyTorch_example_out_01',# delete_tmp_folder_after_terminate=False,# delete_output_folder_after_terminate=False,seed=42,
)api.search(X_train=X_train,y_train=y_train,X_test=X_test.copy(),y_test=y_test.copy(),dataset_name='Australian',optimize_metric='accuracy',total_walltime_limit=300,func_eval_time_limit_secs=50,#n_jobs= -1,memory_limit=None
)

api.search时,如果只加入了官网代码会报错

ValueError: current limit exceeds maximum limit

所以需要加上:

memory_limit=None

y_pred = api.predict(X_test)
score = api.score(y_pred, y_test)
print(score)# Print statistics from search
print(api.sprint_statistics())

{‘accuracy’: 0.8728323699421965}
autoPyTorch results:
Dataset name: Australian
Optimisation Metric: accuracy
Best validation score: 0.8713450292397661
Number of target algorithm runs: 52
Number of successful target algorithm runs: 6
Number of crashed target algorithm runs: 45
Number of target algorithms that exceeded the time limit: 1
Number of target algorithms that exceeded the memory limit: 0

这样就运行完成了
下一节,讲一下具体的用法

相关内容

热门资讯

摸摸你的腰mp3 摸摸你的腰mp3摸摸你的腰mp3... 摸摸你的腰mp3 展开 好多水我摸摸你的头好温柔,我...
最近书荒啊,谁有没有好看的言情... 最近书荒啊,谁有没有好看的言情小说介绍一些啊!不配【有三部】,赶夫上轿【轻松】,南风过境【宠文】,花...
金饰克价再次涨至1000元!黄... 本文来自微信公众号“大象新闻”6月30日,现货黄金盘中一度跌至一个月内新低,随后开始大幅反弹,收报3...
西安警方回应“中华田园犬禁养”... 6月30日,网传陕西省西安市公安局限制养犬管理办公室发布的“重点限养区禁止饲养烈性犬和大型犬”图片引...
小学生常常以教师的行为为榜样,... 小学生常常以教师的行为为榜样,教师也处处表现出对表现好的学生的喜爱和认可,学生从中获得派生地位。这种...
香港维持对日本水产进口管制 作者 | 《财经》特派香港记者 焦建 编辑 | 苏琦  日本水产及日式料理多年来受港人追捧,日本水产...
成都先导终止收购海纳医药65%... 6月30日,成都先导药物开发股份有限公司(以下简称“成都先导”)宣布,因未能就交易事项的核心条款达成...
11岁女孩身高137cm,警惕...   炒股就看金麒麟分析师研报,权威,专业,及时,全面,助您挖掘潜力主题机会! 转自:医学界*仅供医...
《勇气》阅读题理解 《勇气》阅读题理解 19世纪,在英国的名门公立学校—哈罗学校常常会出现以强凌弱、以大欺小的事情。...
建设银行再创历史新高!牵手“山...   炒股就看金麒麟分析师研报,权威,专业,及时,全面,助您挖掘潜力主题机会!   中国基金报记者 ...