Skip to content

Commit

Permalink
Merge pull request #1403 from rstudio/cran-v3-0.1.0
Browse files Browse the repository at this point in the history
CRAN Release keras3 v0.1.0
  • Loading branch information
t-kalinowski authored Feb 19, 2024
2 parents d84c030 + e3bebf3 commit 2147361
Show file tree
Hide file tree
Showing 54 changed files with 161 additions and 39 deletions.
2 changes: 2 additions & 0 deletions R/LearningRateSchedule.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
#'
#' @param call,initialize,get_config
#' Recommended methods to implement. See description and details sections.
#' @returns A function that returns `LearningRateSchedule` instances, similar to the
#' built-in `learning_rate_schedule_*` family of functions.
#' @tether keras.optimizers.schedules.LearningRateSchedule
#' @inheritSection Layer Symbols in scope
#' @inheritParams Layer
Expand Down
5 changes: 5 additions & 0 deletions R/history.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ print.keras_training_history <- function(x, ...) {
#'
#' @importFrom rlang .data
#'
#' @returns if `method == "ggplot2"`, the ggplot object is returned. If
#' `method == "base"`, then this function will draw to the graphics device and
#' return `NULL`, invisibly.
#'
#' @export
plot.keras_training_history <- function(x, y, metrics = NULL, method = c("auto", "ggplot2", "base"),
smooth = getOption("keras.plot.history.smooth", TRUE),
Expand Down Expand Up @@ -171,6 +175,7 @@ plot.keras_training_history <- function(x, y, metrics = NULL, method = c("auto",
else
graphics::legend(legend_location, legend = metric, pch = 1)
}
invisible(NULL)
}
}

Expand Down
5 changes: 5 additions & 0 deletions R/model-persistence.R
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,18 @@ load_model_config <- function(filepath, custom_objects = NULL)
#'
#' @param object A keras model.
#'
#' @returns This is called primarily for the side effect of exporting `object`.
#' The first argument, `object` is also returned, invisibly, to enable usage
#' with the pipe.
#'
#' @exportS3Method tensorflow::export_savedmodel
#' @tether keras.Model.export
#' @family saving and loading functions
# @seealso
# + <https://www.tensorflow.org/api_docs/python/tf/keras/Model/export>
export_savedmodel.keras.src.models.model.Model <- function(object, export_dir_base, ...) {
object$export(export_dir_base, ...)
invisible(object)
}


Expand Down
4 changes: 4 additions & 0 deletions R/model-training.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
#' wrapped in a `LossScaleOptimizer`, which will dynamically
#' scale the loss to prevent underflow.
#'
#' @returns This is called primarily for the side effect of modifying `object`
#' in-place. The first argument `object` is also returned, invisibly, to
#' enable usage with the pipe.
#'
#' @param object Keras model object
#' @param ... Additional arguments passed on to the `compile()` model method.
#' @export
Expand Down
14 changes: 7 additions & 7 deletions R/ops.R
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ keras$ops$elu(x, alpha)
#' ```
#'
#'
#' ```{r op_gelu-plot}
#' ```{r op-gelu-plot}
#' x <- seq(-5, 5, .1)
#' plot(x, op_gelu(x),
#' type = "l", #, frame.plot = FALSE,
Expand Down Expand Up @@ -1816,7 +1816,7 @@ keras$ops$gelu(x, approximate)
#' op_hard_sigmoid(x)
#' ```
#'
#' ```{r op_hard_sigmoid-plot}
#' ```{r op-hard-sigmoid-plot}
#' x <- as.array(seq(-5, 5, .1))
#' plot(x, op_hard_sigmoid(x),
#' type = 'l', panel.first = grid(), frame.plot = FALSE)
Expand Down Expand Up @@ -1853,7 +1853,7 @@ keras$ops$hard_sigmoid(x)
#' op_leaky_relu(x)
#' # array([-0.2, 0. , 1. ], shape=(3,), dtype=float64)
#' ```
#' ```{r op_leaky_relu-plot}
#' ```{r op-leaky-relu-plot}
#' x <- seq(-5, 5, .1)
#' plot(x, op_leaky_relu(x),
#' type = 'l', panel.first = grid())
Expand Down Expand Up @@ -2166,7 +2166,7 @@ function (x, num_classes, axis = -1L, dtype = NULL)
#' op_relu(x1)
#' ```
#'
#' ```{r op_relu-plot}
#' ```{r op-relu-plot}
#' x <- seq(-10, 10, .1)
#' plot(x, op_relu(x))
#' ```
Expand Down Expand Up @@ -2199,7 +2199,7 @@ keras$ops$relu(x)
#' x <- op_convert_to_tensor(c(-3, -2, 0.1, 0.2, 6, 8))
#' op_relu6(x)
#' ```
#' ```{r op_relu6-plot}
#' ```{r op-relu6-plot}
#' x <- seq(-10, 10, .1)
#' plot(x, op_relu6(x))
#' ```
Expand Down Expand Up @@ -2439,7 +2439,7 @@ function (x, axis = -1L)
#' x <- op_convert_to_tensor(c(-0.555, 0, 0.555))
#' op_softplus(x)
#' ```
#' ```{r op_softplus-plot}
#' ```{r op-softplus-plot}
#' x <- seq(-10, 10, .1)
#' plot(x, op_softplus(x))
#' ```
Expand Down Expand Up @@ -2472,7 +2472,7 @@ keras$ops$softplus(x)
#' x <- op_convert_to_tensor(c(-0.100, -10.0, 1.0, 0.0, 100.0))
#' op_softsign(x)
#' ```
#' ```{r op_softsign-plot}
#' ```{r op-softsign-plot}
#' x <- seq(-10, 10, .1)
#' plot(x, op_softsign(x), ylim = c(-1, 1))
#' ```
Expand Down
6 changes: 6 additions & 0 deletions R/reexports.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @returns Most commonly, the result of calling the right hand side with the
#' left hand side as an argument: `rhs(lhs)`. See the magritter vignette for
#' other, more advanced, usages.
#' @export
#' @export
#' @importFrom magrittr %<>% %>%
#' @usage lhs \%>\% rhs
Expand All @@ -21,6 +25,8 @@ magrittr::`%<>%`
#' @name %<-%
#' @rdname multi-assign
#' @keywords internal
#' @returns The right-hand-side argument, `value`, invisibly. This called
#' primarily for it's side-effect of assigning symbols in the current frame.
#' @export
#' @importFrom zeallot %<-%
#' @usage x \%<-\% value
Expand Down
29 changes: 16 additions & 13 deletions docs/articles/getting_started.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ articles:
writing_a_custom_training_loop_in_torch: writing_a_custom_training_loop_in_torch.html
writing_a_training_loop_from_scratch: writing_a_training_loop_from_scratch.html
writing_your_own_callbacks: writing_your_own_callbacks.html
last_built: 2024-02-12T15:51Z
last_built: 2024-02-19T13:45Z
urls:
reference: https://keras.posit.co/reference
article: https://keras.posit.co/articles
Expand Down
Loading

0 comments on commit 2147361

Please sign in to comment.