【发布时间】:2017-04-25 13:55:34
【问题描述】:
我正在尝试在 R 中制作一些神经网络,在 tensorflow anaconda 环境中的 tensorflow 上使用 kerasR 包。
在这里你可以看到我的设置:
library(reticulate)
use_condaenv("tensorflow", required = TRUE)
py_config()
结果是:
python: C:\Users\Miguel\Anaconda3\envs\tensorflow\python.exe
libpython: C:/Users/Miguel/Anaconda3/envs/tensorflow/python35.dll
pythonhome: C:\Users\Miguel\ANACON~1\envs\TENSOR~1
version: 3.5.3 |Continuum Analytics, Inc.| (default, Feb 22 2017, 21:28:42) [MSC v.1900 64 bit (AMD64)]
Architecture: 64bit
numpy: C:\Users\Miguel\ANACON~1\envs\TENSOR~1\lib\site-packages\numpy
numpy_version: 1.12.1
python versions found:
C:\Users\Miguel\Anaconda3\envs\tensorflow\python.exe
C:\Users\Miguel\ANACON~1\python.exe
这是我的代码:
library(kerasR)
mod <- Sequential()
mod$add(Dense(units = 200, input_shape = 13))
抛出此错误消息:
Error in py_call_impl(callable, dots$args, dots$keywords) :
TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64
Detailed traceback:
File "c:\users\miguel\documents\github\keras\keras\models.py", line 430, in add layer(x)
File "c:\users\miguel\documents\github\keras\keras\engine\topology.py", line 558, in __call__ self.build(input_shapes[0])
File "c:\users\miguel\documents\github\keras\keras\layers\core.py", line 827, in build constraint=self.kernel_constraint)
File "c:\users\miguel\documents\github\keras\keras\legacy\interfaces.py", line 88, in wrapper return func(*args, **kwargs)
File "c:\users\miguel\documents\github\keras\keras\engine\topology.py", line 391, in add_weight weight = K.variable(initializer(shape), dtype=dtype, name=name)
File "c:\users\miguel\documents\github\keras\keras\initializers.py", line 208, in __call__ dtype=dtype, seed=self.seed)
File "c:\users\miguel\documents\github\keras\keras\backend\tensorflow_backend.py", l
不幸的是,我找不到有关此 R / kerasR / tensrflow / anaconda 设置的建议。我们将非常感谢您的帮助。
我的会话信息:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] kerasR_0.4.1 reticulate_0.7
loaded via a namespace (and not attached):
[1] tools_3.3.2 Rcpp_0.12.10 knitr_1.15
【问题讨论】:
-
你需要传递int,而不是float
标签: r tensorflow anaconda keras