我正在Rstudio中使用Keras进行深度学习。我复制并粘贴了此链接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)
Matrix产品:默认
语言环境: [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数据集方法基础
其他附件包: [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
答案 0 :(得分:2)
能否请您尝试提及here的修复程序。
如果链接断开,还可以提供以下解决方案-
要安装此修补程序,您应该确保关闭所有R会话,然后打开一个新的R会话并执行:
devtools::install_github("rstudio/reticulate")
您需要关闭所有R会话的原因是,如果Windows共享库在安装过程中正在使用中,则它们不会被成功覆盖。
希望这可以解决您遇到的问题。