py_call_impl中的Keras错误(可调用,点$ args,点$关键字): [英] Keras Error in py_call_impl(callable, dots$args, dots$keywords) :

查看:123
本文介绍了py_call_impl中的Keras错误(可调用,点$ args,点$关键字):的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Rstudio中使用Keras进行深度学习.我复制并粘贴此链接

I am doing deep learning using Keras in Rstudio.I copy and paste this link https://tensorflow.rstudio.com/tutorials/beginners/basic-ml/tutorial_basic_regression/

boston_housing <- dataset_boston_housing()

c(train_data, train_labels) %<-% boston_housing$train
c(test_data, test_labels) %<-% boston_housing$test

paste0("Training entries: ", length(train_data), ", labels: ", length(train_labels))

train_data[1, ] # Display sample features, notice the different scales

library(dplyr)

column_names <- c('CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 
                  'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT')

train_df <- train_data %>% 
  as_tibble(.name_repair = "minimal") %>% 
  setNames(column_names) %>% 
  mutate(label = train_labels)

test_df <- test_data %>% 
  as_tibble(.name_repair = "minimal") %>% 
  setNames(column_names) %>% 
  mutate(label = test_labels)

train_labels[1:10] # Display first 10 entries

spec <- feature_spec(train_df, label ~ . ) %>% 
  step_numeric_column(all_numeric(), normalizer_fn = scaler_standard()) 

spec <- fit(spec)

layer <- layer_dense_features(
  feature_columns = dense_features(spec), 
  dtype = tf$float32
)

layer(train_df)

layer(train_df)

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  ValueError: ('We expected a dictionary here. Instead we got: ',          CRIM    ZN  INDUS  CHAS     NOX  ...    TAX  PTRATIO       B  LSTAT  label
0     1.23247   0.0   8.14   0.0  0.5380  ...  307.0     21.0  396.90  18.72   15.2
1     0.02177  82.5   2.03   0.0  0.4150  ...  348.0     14.7  395.38   3.11   42.3
**sessionInfo()**

R版本3.6.3(2020-02-29)平台:x86_64-w64-mingw32/x64(64位)在以下环境下运行:Windows 10 x64(内部版本18363)

R version 3.6.3 (2020-02-29) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

Matrix产品:默认

Matrix products: default

语言环境:[1] LC_COLLATE = Spanish_Chile.1252 LC_CTYPE = Spanish_Chile.1252 LC_MONETARY = Spanish_Chile.1252[4] LC_NUMERIC = C LC_TIME = Spanish_Chile.1252

locale: [1] LC_COLLATE=Spanish_Chile.1252 LC_CTYPE=Spanish_Chile.1252 LC_MONETARY=Spanish_Chile.1252 [4] LC_NUMERIC=C LC_TIME=Spanish_Chile.1252

附带的基本软件包:[1]统计图形grDevices utils数据集方法基础

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

其他附带的软件包:[1] dplyr_0.8.5 tfdatasets_2.0.0 keras_2.2.5.0 tensorflow_2.0.0

other attached packages: [1] dplyr_0.8.5 tfdatasets_2.0.0 keras_2.2.5.0 tensorflow_2.0.0

通过名称空间(未附加)加载:[1] Rcpp_1.0.3支柱_1.4.3编译器_3.6.3 prettyunits_1.1.1 base64enc_0.1-3工具_3.6.3
[7] progress_1.2.2 zeallot_0.1.0摘要_0.6.25 packrat_0.5.0 jsonlite_1.6.1评估_0.14
[13] tibble_2.1.3 pkgconfig_2.0.3 rlang_0.4.5 cli_2.0.2 rstudioapi_0.11 yaml_2.2.1
[19] xfun_0.12 knitr_1.28泛型_0.0.2 vctrs_0.2.4 rappdirs_0.3.1 hms_0.5.3
[25] tidyselect_1.0.0网纹_1.14胶水_1.3.2锻造_0.2.0 R6_2.4.1粉丝i_0.4.1
[31] rmarkdown_2.1 purrr_0.3.3 magrittr_1.5 whisker_0.4 tfestimators_1.9.1 tfruns_1.4
[37] htmltools_0.4.0断言_0.2.1 crayon_1.3.4

loaded via a namespace (and not attached): [1] Rcpp_1.0.3 pillar_1.4.3 compiler_3.6.3 prettyunits_1.1.1 base64enc_0.1-3 tools_3.6.3
[7] progress_1.2.2 zeallot_0.1.0 digest_0.6.25 packrat_0.5.0 jsonlite_1.6.1 evaluate_0.14
[13] tibble_2.1.3 pkgconfig_2.0.3 rlang_0.4.5 cli_2.0.2 rstudioapi_0.11 yaml_2.2.1
[19] xfun_0.12 knitr_1.28 generics_0.0.2 vctrs_0.2.4 rappdirs_0.3.1 hms_0.5.3
[25] tidyselect_1.0.0 reticulate_1.14 glue_1.3.2 forge_0.2.0 R6_2.4.1 fansi_0.4.1
[31] rmarkdown_2.1 purrr_0.3.3 magrittr_1.5 whisker_0.4 tfestimators_1.9.1 tfruns_1.4
[37] htmltools_0.4.0 assertthat_0.2.1 crayon_1.3.4

推荐答案

能否请您尝试提到的修补程序

Can you please try the fix mentioned here.

如果链接断开,也可以提供以下解决方案-

Provided the solution below as well if in case the link is broken -

要安装此修补程序,您应该确保关闭所有R会话,然后打开一个新的R会话并执行:

To install the fix you should be sure to close all R sessions then open a fresh R session and execute:

devtools::install_github("rstudio/reticulate")

您需要关闭所有R会话的原因是,如果Windows共享库在安装期间正在使用中,则它们不会被成功覆盖.

The reason you need to close all R sessions is that windows shared libraries won't be successfully overwritten if they are in use during the installation.

希望这可以解决您遇到的问题.

Hope this works and fixes the issue you are facing.

这篇关于py_call_impl中的Keras错误(可调用,点$ args,点$关键字):的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆