Mar*_*ark 2 python r conda keras
我正在尝试keras-bert按照此处的说明进行安装:BERT from R。R本教程展示了如何使用加载和训练 BERT 模型Keras。
但是,当我在 Anaconda 提示符 (Windows) 中运行:
conda install keras-bert
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- keras-bert
Current channels:
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Run Code Online (Sandbox Code Playgroud)
我还导航到https://anaconda.org,搜索keras-bert,但没有找到此搜索的项目。
我也尝试过:
python3 -m pip install keras-bert
Run Code Online (Sandbox Code Playgroud)
我没有得到任何输出:
(base) C:\Users\Standard>python3 -m pip install keras-bert
(base) C:\Users\Standard>
Run Code Online (Sandbox Code Playgroud)
但是当我用 R 命令检查 keras-bert 是否安装时
reticulate::py_module_available('keras_bert')
Run Code Online (Sandbox Code Playgroud)
我获得了:
[1] FALSE
Run Code Online (Sandbox Code Playgroud)
由于这需要将 PyPI 包与 Conda 混合,因此最佳实践建议是使用 YAML 文件创建专用环境。您可能需要此处的其他版本约束才能实现与本教程一起使用的设置,但这个 YAML 足以让我执行第一步:
bert_env.yaml
name: bert_env
channels:
- defaults
dependencies:
- numpy
- keras
- pip
- pip:
- keras-bert
Run Code Online (Sandbox Code Playgroud)
跑步
conda env create -f bert_env.yaml
Run Code Online (Sandbox Code Playgroud)
创建名为bert_env 的环境。
从 R 会话中,我可以运行
> reticulate::use_condaenv("bert_env", required=TRUE)
> reticulate::py_config()
# python: /Users/user/miniconda3/envs/bert_env/bin/python
# libpython: /Users/user/miniconda3/envs/bert_env/lib/libpython3.6m.dylib
# pythonhome: /Users/user/miniconda3/envs/bert_env:/Users/user/miniconda3/envs/bert_env
# version: 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 23:06:31) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
# numpy: /Users/user/miniconda3/envs/bert_env/lib/python3.6/site-packages/numpy
# numpy_version: 1.18.5
> reticulate::py_module_available("keras_bert")
# [1] TRUE
> tensorflow::tf_config()
# TensorFlow v2.0.0 ()
# Python v3.6 (~/miniconda3/envs/bert_env/bin/python)
Run Code Online (Sandbox Code Playgroud)
这一切都在osx-64平台上运行,因此win-64可能会在其下拉的版本上有所不同。但最终,主要应该是调整 YAML的问题。
| 归档时间: |
|
| 查看次数: |
1771 次 |
| 最近记录: |