lancopku / AdaMod

Adaptive and Momental Bounds for Adaptive Learning Rate Methods.
Apache License 2.0
127 stars 27 forks source link

How to install optimizer AdaMod into Keras/Reticulate virtual environment? #2

Open faltinl opened 4 years ago

faltinl commented 4 years ago

I am working with Keras for R to experiment with neural networks and I use a Conda virtual environment under Reticulate to occasionally access additional Python packages. My attempt to install optimizer AdaMod, however, fails. I keep getting the following results (to be seen within R under RStudio):

> library(reticulate)
> conda_list()
          name                                         python
1   Miniconda3                     C:\\Miniconda3\\python.exe
2 r-reticulate C:\\Miniconda3\\envs\\r-reticulate\\python.exe
> reticulate::use_virtualenv("C:\\Miniconda3\\envs\\r-reticulate")

Thus, my virtual environment is there and working. Now I continue:

> py_install("adamod")
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##
  environment location: C:\Miniconda3\envs\r-reticulate
  added / updated specs:
    - python
The following packages will be downloaded:
    package                    |            build
    ---------------------------|-----------------
    certifi-2020.6.20          |           py36_0         156 KB
    ------------------------------------------------------------
                                           Total:         156 KB

The following packages will be UPDATED:
  certifi                                 2020.4.5.1-py36_0 --> 2020.6.20-py36_0

Downloading and Extracting Packages
certifi-2020.6.20    | 156 KB    | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:
  - adamod
Current channels:
  - https://conda.anaconda.org/conda-forge/win-64
  - https://conda.anaconda.org/conda-forge/noarch
  - 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
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.

Error: one or more Python packages failed to install [error code 1]

Under the address https://anaconda.org I can't find anything useful.
Question: how should I proceed to get the AdaMod package installed and available within my R environment as required? Thanks in advance for any useful hint!

Note: This issue is related to the issue Transfer of a new Python optimizer to Keras in R rstudio / keras #1049

karrynest commented 4 years ago

Tensorflow 2.0 version: https://github.com/evanatyourservice/AdaMod-tf

Keras + Tensorflow 1.x version of AdaMod if anyone interested https://github.com/superkido511/AdaMod-Keras

Hope this can help you :)

faltinl commented 4 years ago

Hi, karrynest and tnx for support and suggestions. In R, i.e. under RStudio, i.e. activated my virtual environment r-reticulate and used it to start the installation process:

> library(reticulate)
> conda_list()
          name                                         python
1   Miniconda3                     C:\\Miniconda3\\python.exe
2 r-reticulate C:\\Miniconda3\\envs\\r-reticulate\\python.exe
> use_condaenv("r-reticulate")
> reticulate::py_install(c("https://github.com/superkido511/AdaMod-Keras"), pip = TRUE)

and got the following answer:

Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
# All requested packages already installed.
Collecting https://github.com/superkido511/AdaMod-Keras
  Downloading https://github.com/superkido511/AdaMod-Keras  ### NOTE: apparently download is working, however...###
  ERROR: Cannot unpack file C:\Users\lf\AppData\Local\Temp\pip-unpack-oc97rttd\AdaMod-Keras 
               (downloaded from C:\Users\lf\AppData\Local\Temp\pip-req-build-7ft3wqj5, content-type: text/html; charset=utf-8); 
               cannot detect archive format
  ERROR: Cannot determine archive format of C:\Users\lf\AppData\Local\Temp\pip-req-build-7ft3wqj5
Error: Error installing package(s): "https://github.com/superkido511/AdaMod-Keras"

Using the other address provided for AdaMod-tf produces exactly the same error message. So there is some problem with unpacking the Python packages. Any idea what could be wrong?

I really don't understand why this process didn't produce the expected result, because it worked quite well in other cases.