0

Developing a Deep Learning with R Keras, and I want to implement earlystopping callback but it displays an error: Error in as.integer(verbose) : cannot coerce type 'environment' to vector of type 'integer'

The R code:

# Compiling the model
model %>% compile(loss = "categorical_crossentropy",
                  optimizer = "adam",
                  
                  metrics = c("accuracy"))

history <- model %>% 
  fit(x_train,
      y_train,
      epoch = 250,
      batch_size = 32,
      callback_early_stopping(monitor = "val_loss", 
                              min_delta = 0.001, 
                              patience = 5,
                              restore_best_weights = TRUE,
                              verbose = 1),
      validation_split = 0.2
      )

Any idea what's wrong? Thanks.

user979974
  • 883
  • 3
  • 13
  • 32
  • I think that the callbacks argument inside `fit` needs to call a list, something like `callbacks = list(early_stopping)`. Try that and see if it works – Jonathan V. Solórzano Apr 16 '21 at 14:24
  • Thanks @JonathanV.Solórzano. You were right, it needs a list inside fit call. `callbacks <- list( callback_early_stopping(monitor = "val_loss", min_delta = 0.001, patience = 5,restore_best_weights = TRUE,verbose = 1))` and then, `..fit(... callback=callbacks)` – user979974 Apr 16 '21 at 14:34

0 Answers0