Skip to content

Commit

Permalink
set default fit(verbose=2) in knitr context
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Aug 9, 2023
1 parent 65c129d commit 6493598
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 3 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

- Default TF version installed by `install_keras()` is now 2.13.

- `install_keras()` `envname` argument default changes to `"r-keras"`. Unless
the `envname` argument is supplied, `install_keras()` will install into a
virtual environment named "r-keras".

- Updated layers:
- `layer_batch_normalization()` updated signature, with changes to options for distributed training.
- `layer_embedding()` gains a `sparse` argument.

- Fixed deadlock when an R generator was passed to `fit()`, `predict()`, and other endpoints.

- When `fit(verbose = "auto")` is evaluated in the context of a knitr document
(e.g., quarto or rmarkdown document being rendered), verbose will now
default to `2`, showing one line per epoch.

# keras 2.11.1

Expand Down
11 changes: 8 additions & 3 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ resolve_main_thread_generators <- function(x, callback_type = "on_train_batch_be
#' not trained for a number of iterations given by `epochs`, but
#' merely until the epoch of index `epochs` is reached.
#' @param verbose Verbosity mode (0 = silent, 1 = progress bar, 2 = one line per
#' epoch).
#' epoch). Defaults to
#' @param view_metrics View realtime plot of training metrics (by epoch). The
#' default (`"auto"`) will display the plot when running within RStudio,
#' `metrics` were specified during model [compile()], `epochs > 1` and
Expand Down Expand Up @@ -674,7 +674,7 @@ resolve_main_thread_generators <- function(x, callback_type = "on_train_batch_be
#' @export
fit.keras.engine.training.Model <-
function(object, x = NULL, y = NULL, batch_size=NULL, epochs=10,
verbose=getOption("keras.fit_verbose", default = "auto"), callbacks=NULL,
verbose = getOption("keras.fit_verbose", default = "auto"), callbacks=NULL,
view_metrics = getOption("keras.view_metrics", default = "auto"),
validation_split=0.0, validation_data=NULL, shuffle=TRUE,
class_weight=NULL, sample_weight=NULL, initial_epoch=0,
Expand Down Expand Up @@ -895,7 +895,12 @@ function(object,
as_model_verbose_arg <- function(x, old_default = 1L) {
if(tf_version() < "2.9" && x == "auto")
return(old_default)
if(x == "auto") x else as.integer(x)
if(!identical(x, "auto"))
return(as.integer(x))
# x == auto
if(isTRUE(getOption('knitr.in.progress')))
return(2L)
x # "auto"
}


Expand Down

0 comments on commit 6493598

Please sign in to comment.