I build a image classification model in R by keras for R.
Got about 98% accuracy, while got terrible accuracy in python.
Keras version for R is 2.1.3, and 2.1.5
That is a dramatic difference so perhaps there's a bug in the code or something unexpected in the data but reproducing Keras
results from R
in Python
is more difficult than it may seem since setting the seed on the R
side is insufficient. Instead of set.seed
you should use use_session_with_seed
, which comes with the R libraries for tensorflow
and keras
. Note that for full reproducibility you need to use_session_with_seed(..., disable_gpu=TRUE, disable_parallel_cpu=TRUE)
. See also stack and tf docs. Also, here is an example using the github version of kerasformula
and a public dataset. Also, watch out for functions like layer_dropout
that accept seed
as a parameter.