Different accuracy between python keras and keras in R

前端 未结 1 1318
借酒劲吻你
借酒劲吻你 2021-02-09 08:53

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

1条回答
  •  -上瘾入骨i
    2021-02-09 09:15

    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.

    0 讨论(0)
提交回复
热议问题