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

安装

实测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

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

相关内容

热门资讯

重大通报作弊器!乐乐上海麻将a... 重大通报作弊器!乐乐上海麻将ai智能透视辅助插件,乐乐上海麻将本来存在有外挂(有辅助挂方略)1、很好...
分享给玩家透视挂!家乡大贰ai... 分享给玩家透视挂!家乡大贰ai智能透视辅助工具,家乡大贰其实真的有外挂(有辅助挂细节)家乡大贰破解侠...
科普攻略开挂!英豪娱乐城ai智... 科普攻略开挂!英豪娱乐城ai智能透视辅助教程,英豪娱乐城好像真的是有外挂(有辅助挂头条)1、英豪娱乐...
总算了解辅助器!和悦游戏ai智... 总算了解辅助器!和悦游戏ai智能透视辅助教程,和悦游戏确实是真的有外挂(竟然有辅助挂)暗藏猫腻,小编...
揭秘关于辅助器!九九麻将ai智... 揭秘关于辅助器!九九麻将ai智能透视辅助技巧,九九麻将一贯是有外挂(有辅助挂方略)1、用户打开应用后...