{"action":"created","issue":{"url":"https://api.github.com/repos/rstudio/keras/issues/267","repository_url":"https://api.github.com/repos/rstudio/keras","labels_url":"https://api.github.com/repos/rstudio/keras/issues/267/labels{/name}","comments_url":"https://api.github.com/repos/rstudio/keras/issues/267/comments","events_url":"https://api.github.com/repos/rstudio/keras/issues/267/events","html_url":"https://github.com/rstudio/keras/issues/267","id":293488216,"number":267,"title":"Export model without restart R session","user":{"login":"quoctuams","id":15074019,"avatar_url":"https://avatars2.githubusercontent.com/u/15074019?v=4","gravatar_id":"","url":"https://api.github.com/users/quoctuams","html_url":"https://github.com/quoctuams","followers_url":"https://api.github.com/users/quoctuams/followers","following_url":"https://api.github.com/users/quoctuams/following{/other_user}","gists_url":"https://api.github.com/users/quoctuams/gists{/gist_id}","starred_url":"https://api.github.com/users/quoctuams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quoctuams/subscriptions","organizations_url":"https://api.github.com/users/quoctuams/orgs","repos_url":"https://api.github.com/users/quoctuams/repos","events_url":"https://api.github.com/users/quoctuams/events{/privacy}","received_events_url":"https://api.github.com/users/quoctuams/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-02-01T11:02:56Z","updated_at":"2018-02-01T17:09:18Z","closed_at":"2018-02-01T17:09:18Z","author_association":"NONE","body":"Hi guys, I'm facing a quite weird situation as follows:\r\nFirst, I ran a basic model like this:\r\n\r\n```\r\nmodel <- keras_model_sequential()\r\nmodel %>%\r\n    layer_dense(units = 256, activation = 'relu', input_shape = c(length(featureList))) %>%\r\n    layer_dropout(rate = 0.4) %>%\r\n    layer_dense(units = 128, activation = 'relu') %>%\r\n    layer_dropout(rate = 0.3) %>%\r\n    layer_dense(units = numCategory, activation = 'softmax')\r\n\r\nmodel %>% compile(\r\n    loss = 'categorical_crossentropy',\r\n    optimizer = optimizer_rmsprop(),\r\n    metrics = c('accuracy')\r\n)\r\n# train model\r\nhistory <- model %>% fit(\r\n    x_train, y_train,\r\n    epochs = 30, batch_size = 25,\r\n    validation_split = 0.2\r\n)\r\n```\r\n\r\nThe accuracy was about 60%.\r\nAfter that, I exported the model using export_savedmodel and re-run the above code (without restarting R as suggested in the console). Surprisingly the accuracy now reached 90% (on training) and 80% (on validating).\r\nThis situation happens again & again with different sets of data. Do you guys have any idea what is going on?"},"comment":{"url":"https://api.github.com/repos/rstudio/keras/issues/comments/362335104","html_url":"https://github.com/rstudio/keras/issues/267#issuecomment-362335104","issue_url":"https://api.github.com/repos/rstudio/keras/issues/267","id":362335104,"user":{"login":"jjallaire","id":104391,"avatar_url":"https://avatars2.githubusercontent.com/u/104391?v=4","gravatar_id":"","url":"https://api.github.com/users/jjallaire","html_url":"https://github.com/jjallaire","followers_url":"https://api.github.com/users/jjallaire/followers","following_url":"https://api.github.com/users/jjallaire/following{/other_user}","gists_url":"https://api.github.com/users/jjallaire/gists{/gist_id}","starred_url":"https://api.github.com/users/jjallaire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjallaire/subscriptions","organizations_url":"https://api.github.com/users/jjallaire/orgs","repos_url":"https://api.github.com/users/jjallaire/repos","events_url":"https://api.github.com/users/jjallaire/events{/privacy}","received_events_url":"https://api.github.com/users/jjallaire/received_events","type":"User","site_admin":false},"created_at":"2018-02-01T17:09:18Z","updated_at":"2018-02-01T17:09:18Z","author_association":"OWNER","body":"What's happening is that with the learning phase set to 0, the dropout layers are effectively disabled, so your model ends up with much worse overfitting (thus the high delta between accuracy and validation accuracy). You'll see the same behavior in a fresh session if you remove the dropout layers:\r\n\r\n```r\r\nmodel <- keras_model_sequential()\r\nmodel %>%\r\n  layer_dense(units = 256, activation = 'relu', input_shape = c(ncol(x_train))) %>%\r\n  layer_dense(units = 128, activation = 'relu') %>%\r\n  layer_dense(units = 3, activation = 'softmax')\r\n```"}}
{"actor":{"display_login":"jjallaire"}}