-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installation Issue #1491
Comments
Hi, thanks for reporting. This error occurs if you are using Can you please try the development version of keras3 and let me know if this works for you? pak::pak("rstudio/keras3")
print(keras3::op_convert_to_tensor("Hello World!"))
print(reticulate::py_config()) |
Thank you Tomasz, I ran these three commands in RStudio, it gave the following output: pak::pak("rstudio/keras3") → Will update 2 packages.
! keras3 and reticulate are loaded in the current R session, you probably need to restart R after the installation. ? Do you want to continue (Y/n) print(keras3::op_convert_to_tensor("Hello World!"))
I restarted RStudio and tried running again the same code from Chap 2 of the Chollet book, but when I got to the same snippet in my original post: model <- keras_model_sequential(list( But I am still getting the same error. Do you have anything else that I can try? |
Added information to last post: |
What is the output of |
|
|
|
Can you please run: reticulate::virtualenv_remove("r-reticulate") Alternatively, you can also use the unexported reticulate:::rm_all_reticulate_state(TRUE) Then try to use keras again. |
I just ran the first option, and tried to build the keras3 model again, but I am getting the same error mssg:
|
Oh I apologize, the keras3 error message now (above) is different. |
No need to reinstall the R package. It looks like you need to restart your R session and call |
Thank you Tomasz for all of your prompt follow-ups. |
Happy Birthday! |
Good Morning Tomasz, I have closed all my running RStudio sessions/projects and restarted the one where I am trying to make keras3 work. I redid the library command for keras3 (as you suggested) + for tensor flow. The same code snippet (the model creation) gave an error mssg that was longer than before but the last part was the same as before; here is all the i/o:
'''Attaching package: ‘tensorflow’ The following objects are masked from ‘package:keras3’:
|
Hi, I can't reproduce the error locally. Can you use Also, please make sure you're running the latest version of the R packages, and to help keep things reproducible, make sure you're using a reticulate-managed python installation. remotes::install_github("rstudio/reticulate")
remotes::install_github("rstudio/keras3") Sys.setenv("RETICULATE_PYTHON"="managed") |
Hi Tomasz, I have installed the latest version of R and also of R Studio and have run those commands and the keras3 model creation command. The latter produced a new error mssg (about Python) so I am going to try to restart the R session and retry (and will let you know soon what happens. But before I do that I wanted to give you all of the outputs of the commands in your last message that you asked me to run, before they get lost after restarting R(studio):
1: All Enter one or more numbers, or an empty line to skip updates: 1 trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/rlang_1.1.5.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/jsonlite_1.9.1.zip' package ‘Rcpp’ successfully unpacked and MD5 sums checked The downloaded binary packages are in
1: All Enter one or more numbers, or an empty line to skip updates: 1 trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/jsonlite_1.9.1.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/Rcpp_1.0.14.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/glue_1.8.0.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/cli_3.6.4.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/reticulate_1.41.0.zip' package ‘rlang’ successfully unpacked and MD5 sums checked The downloaded binary packages are in
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/cachem_1.1.0.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/memoise_2.0.1.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/mime_0.12.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/sass_0.4.9.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/digest_0.6.37.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/evaluate_1.0.3.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/highr_0.11.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/xfun_0.51.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/bslib_0.9.0.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/fontawesome_0.5.3.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/htmltools_0.5.8.1.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/jquerylib_0.1.4.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/tinytex_0.56.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/callr_3.7.6.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/clipr_0.8.0.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/fs_1.6.5.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/knitr_1.49.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/rmarkdown_2.29.zip' trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/reprex_2.1.1.zip' package ‘cachem’ successfully unpacked and MD5 sums checked The downloaded binary packages are in
'''Attaching package: ‘tensorflow’ The following objects are masked from ‘package:keras3’:
|
I've just restarted R studio and tried the Chollet book code snipet again. Now I am getting an earlier seen error mssg again:
'''Attaching package: ‘tensorflow’ The following objects are masked from ‘package:keras3’:
|
The repeated messages like this:
indicate that your attempt to update R packages is not working. This is sometimes an issue on Windows, where it is not possible to delete a file while another process has the file open.
By the way, you can format code chunks in github with triple backticks. |
Thankyou Tomasz, It is good to know why such error mssgs happen and I will next (and in the future) aim to install all R packages in a fresh empty R session--I will create a new "empty" project just for such purposes. I'll get back to you later after I try all this, and will keep my fingers crossed. BTW, thanks for correcting my use of the wrong tic for code formatting. |
Hi Tomasz, I used the first method you suggested (work on an empty RStudio project) and redid those commands you gave before. Things looked good (the packages now seemed to update correctly) so I did not save the output, closed the R session and reopened my "deep learning project" to run those commands. But I am again getting that same error mssg:
Attaching package: ‘tensorflow’ The following objects are masked from ‘package:keras3’:
|
|
The whole code snippet (that I enclosed in triple back tics) did not paste completely in the above two attempts, here is the code:
|
Thanks Alex, this reminded me that the arguments to Note that that usage pattern is only used once early on for didactic purposes. The more common usage pattern is to compose with keras_model_sequential() |>
layer_*() |>
layer_*() ... You may want to consult https://github.com/jonbry/deep-learning-with-R-2nd-edition-code-keras3, where @jonbry has kindly updated all code examples from the book for |
Many thanks Tomasz; I am delighted that it finally works now on my PCs! Best, Alex |
This is my first time putting up an issue in GitHub, so I apologize in advance in case I may be doing something improperly in this submission.
I've been reading the 2nd edition of Chollet's book for a while now and REALLY hope to start using keras + tensorflow.
I have done following the installation instructions in Chap 3 for my PC:
install.packages("keras3")
reticulate::install_python("3.11")
keras3::install_keras()
When I paste (in order) all of the RCode snippets from Chap 2 to build the first network, all seems to work fine till I run the snippet:
model <- keras_model_sequential(list(
layer_dense(units = 512, activation = "relu"),
layer_dense(units = 10, activation = "softmax")
))
I get this error message:
'''Error in keras_model_sequential(list(layer_dense(units = 512, activation = "relu"), :
layers
must be passed in as a named argument.'''I'd very much appreciate anyone's help or advice on this.
My background: I am a professor in math and statistics and have been teaching machine learning every year for 8 years and have been using R for 13 years. I've never used Python nor needed to install it till I installed keras3. I am planning a new course in deep learning, but I need to work out such bugs and issues so as to avoid my students running into them. I need a powerful software but also a stable working environment.
My email address is [email protected] in case you need or would prefer to contact me directly on this issue.
The text was updated successfully, but these errors were encountered: