为了在 R 中拟合分类模型,一直在使用library(KerasR)
. 控制学习率和KerasR说
compile(optimizer=Adam(lr = 0.001, beta_1 = 0.9, beta_2 = 0.999, epsilon = 1e-08, decay = 0, clipnorm = -1, clipvalue = -1), loss = 'binary_crossentropy', metrics = c('categorical_accuracy') )
但它给了我这样的错误
模块错误$keras.optimizers$Adam(lr = lr, beta_1 = beta_2, beta_2 = beta_2, : 尝试应用非函数
我也用过keras_compile
仍然得到同样的错误。我可以在编译时更改优化器,但最大学习率为 0.01,我想尝试 0.2。
model <- keras_model_sequential()
model %>% layer_dense(units = 512, activation = 'relu', input_shape = ncol(X_train)) %>%
layer_dropout(rate = 0.2) %>%
layer_dense(units = 128, activation = 'relu')%>%
layer_dropout(rate = 0.1) %>%
layer_dense(units = 2, activation = 'sigmoid')%>%
compile(
optimizer = 'Adam',
loss = 'binary_crossentropy',
metrics = c('categorical_accuracy')
)