Hello everyone,
I am using a simple synthetic dataset to train neural network with one hidden layer and two neurons.
- But I am surprised to see that 'nnet' (in 'caret') performs better than 'kerasR'.
- I also used model agnostics such as pdp and ICE, which also suggest that nnet is able to recover the true data generation process better than keras.
Can someone please point out the mistake,
- Am I comparing 'apples' to 'oranges', using different epochs
- Am I using wrong optimization algorithm in kerasR
nnet code -
myControl <- caret::trainControl(## n-fold CV
method = "repeatedcv",
number = 5,
repeats = 1,
verboseIter = TRUE)nnGrid <- expand.grid(size = 2,
decay = seq(0, 0.6, 0.1))nnetFit <- caret::train(choice ~ .,
data = tbl,
method = "nnet",
tuneGrid = nnGrid,
trace = FALSE,
maxit = 1000,
trControl = myControl)
keras model -
model <- keras_model_sequential()
model %>%
layer_dense(units = 2, activation = "sigmoid", input_shape = ncol(train_x)) %>%
layer_dense(units = 1, activation = "sigmoid")model %>% compile(
loss = "binary_crossentropy",
optimizer = "rmsprop",
metrics = c("accuracy")
)model %>%
fit(train_x, train_y,
epochs = 400, batch_size = 64,
verbose = 0)