Skip to content

Error in py_call_impl(callable, dots$args, dots$keywords) in 3-changes.R #37

@ferygood

Description

@ferygood

Hello,

I am learning in chapter 3: Changes to workflow. After sourcing R scripts and make(plan), everything seems fine. However, when I use readd(best_model) to see the the output, it returns me an error as bellow:

>source("R/packages.R")
>source("R/functions.R")
>source("R/plan.R")
>print(plan)

A tibble: 7 x 3
  target      command                                                   format
  <chr>       <expr_lst>                                                <chr> 
1 churn_data  split_data(file_in("../data/customer_churn.csv"))       … <NA>  
2 churn_reci… prepare_recipe(churn_data)                              … <NA>  
3 run_relu    test_model(act1 = "relu", churn_data, churn_recipe)     … <NA>  
4 run_sigmoid test_model(act1 = "sigmoid", churn_data, churn_recipe)  … <NA>  
5 run_softmax test_model(act1 = "softmax", churn_data, churn_recipe)  … <NA>  
6 best_run    rbind(run_relu, run_sigmoid, run_softmax) %>% top_n(1, a… <NA>  
7 best_model  train_best_model(best_run, churn_recipe)                … keras 

>make(plan)
✓ All targets are already up to date.

>readd(best_model)
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  AttributeError: 'str' object has no attribute 'decode'

Detailed traceback:
  File "/Users/yaochung41/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/tensorflow/python/keras/saving/save.py", line 207, in load_model
    compile)
  File "/Users/yaochung41/Library/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 182, in load_model_from_hdf5
    model_config = json_utils.decode(model_config.decode('utf-8'))

I did not find similar closed issues, so I would like to ask if you can help me with this problem. Many thanks!

Here is my sessionInfo:

>sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] yardstick_0.0.8   recipes_0.1.16    rsample_0.1.0     forcats_0.5.1    
 [5] stringr_1.4.0     dplyr_1.0.6       purrr_0.3.4       readr_1.4.0      
 [9] tidyr_1.1.3       tibble_3.1.2      ggplot2_3.3.3     tidyverse_1.3.1  
[13] keras_2.4.0       drake_7.13.2.9000

loaded via a namespace (and not attached):
 [1] fs_1.5.0           lubridate_1.7.10   filelock_1.0.2    
 [4] progress_1.2.2     httr_1.4.2         tools_4.0.5       
 [7] backports_1.2.1    utf8_1.2.1         R6_2.5.0          
[10] rpart_4.1-15       DBI_1.1.1          colorspace_2.0-1  
[13] nnet_7.3-15        withr_2.4.2        tidyselect_1.1.1  
[16] prettyunits_1.1.1  compiler_4.0.5     cli_2.5.0         
[19] rvest_1.0.0        xml2_1.3.2         scales_1.1.1      
[22] tfruns_1.5.0       digest_0.6.27      txtq_0.2.4        
[25] rmarkdown_2.8      base64enc_0.1-3    pkgconfig_2.0.3   
[28] htmltools_0.5.1.1  parallelly_1.25.0  dbplyr_2.1.1      
[31] htmlwidgets_1.5.3  rlang_0.4.11       readxl_1.3.1      
[34] rstudioapi_0.13    generics_0.1.0     jsonlite_1.7.2    
[37] tensorflow_2.4.0   magrittr_2.0.1     Matrix_1.3-2      
[40] Rcpp_1.0.6         munsell_0.5.0      fansi_0.4.2       
[43] reticulate_1.20    lifecycle_1.0.0    furrr_0.2.2       
[46] pROC_1.17.0.1      stringi_1.6.2      whisker_0.4       
[49] yaml_2.2.1         MASS_7.3-53.1      storr_1.2.5       
[52] plyr_1.8.6         grid_4.0.5         parallel_4.0.5    
[55] listenv_0.8.0      crayon_1.4.1       lattice_0.20-41   
[58] haven_2.4.1        splines_4.0.5      hms_1.1.0         
[61] zeallot_0.1.0      knitr_1.33         pillar_1.6.1      
[64] igraph_1.2.6       base64url_1.4      codetools_0.2-18  
[67] reprex_2.0.0       glue_1.4.2         evaluate_0.14     
[70] modelr_0.1.8       png_0.1-7          vctrs_0.3.8       
[73] cellranger_1.1.0   gtable_0.3.0       future_1.21.0     
[76] assertthat_0.2.1   xfun_0.23          gower_0.2.2       
[79] prodlim_2019.11.13 broom_0.7.6        class_7.3-18      
[82] survival_3.2-10    timeDate_3043.102  lava_1.6.9        
[85] globals_0.14.0     ellipsis_0.3.2     ipred_0.9-11   

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions