Skip to content

Commit 2147361

Browse files
authored
Merge pull request #1403 from rstudio/cran-v3-0.1.0
CRAN Release keras3 v0.1.0
2 parents d84c030 + e3bebf3 commit 2147361

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+161
-39
lines changed

R/LearningRateSchedule.R

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
#'
7878
#' @param call,initialize,get_config
7979
#' Recommended methods to implement. See description and details sections.
80+
#' @returns A function that returns `LearningRateSchedule` instances, similar to the
81+
#' built-in `learning_rate_schedule_*` family of functions.
8082
#' @tether keras.optimizers.schedules.LearningRateSchedule
8183
#' @inheritSection Layer Symbols in scope
8284
#' @inheritParams Layer

R/history.R

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ print.keras_training_history <- function(x, ...) {
6161
#'
6262
#' @importFrom rlang .data
6363
#'
64+
#' @returns if `method == "ggplot2"`, the ggplot object is returned. If
65+
#' `method == "base"`, then this function will draw to the graphics device and
66+
#' return `NULL`, invisibly.
67+
#'
6468
#' @export
6569
plot.keras_training_history <- function(x, y, metrics = NULL, method = c("auto", "ggplot2", "base"),
6670
smooth = getOption("keras.plot.history.smooth", TRUE),
@@ -171,6 +175,7 @@ plot.keras_training_history <- function(x, y, metrics = NULL, method = c("auto",
171175
else
172176
graphics::legend(legend_location, legend = metric, pch = 1)
173177
}
178+
invisible(NULL)
174179
}
175180
}
176181

R/model-persistence.R

+5
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,18 @@ load_model_config <- function(filepath, custom_objects = NULL)
341341
#'
342342
#' @param object A keras model.
343343
#'
344+
#' @returns This is called primarily for the side effect of exporting `object`.
345+
#' The first argument, `object` is also returned, invisibly, to enable usage
346+
#' with the pipe.
347+
#'
344348
#' @exportS3Method tensorflow::export_savedmodel
345349
#' @tether keras.Model.export
346350
#' @family saving and loading functions
347351
# @seealso
348352
# + <https://www.tensorflow.org/api_docs/python/tf/keras/Model/export>
349353
export_savedmodel.keras.src.models.model.Model <- function(object, export_dir_base, ...) {
350354
object$export(export_dir_base, ...)
355+
invisible(object)
351356
}
352357

353358

R/model-training.R

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@
119119
#' wrapped in a `LossScaleOptimizer`, which will dynamically
120120
#' scale the loss to prevent underflow.
121121
#'
122+
#' @returns This is called primarily for the side effect of modifying `object`
123+
#' in-place. The first argument `object` is also returned, invisibly, to
124+
#' enable usage with the pipe.
125+
#'
122126
#' @param object Keras model object
123127
#' @param ... Additional arguments passed on to the `compile()` model method.
124128
#' @export

R/ops.R

+7-7
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ keras$ops$elu(x, alpha)
17741774
#' ```
17751775
#'
17761776
#'
1777-
#' ```{r op_gelu-plot}
1777+
#' ```{r op-gelu-plot}
17781778
#' x <- seq(-5, 5, .1)
17791779
#' plot(x, op_gelu(x),
17801780
#' type = "l", #, frame.plot = FALSE,
@@ -1816,7 +1816,7 @@ keras$ops$gelu(x, approximate)
18161816
#' op_hard_sigmoid(x)
18171817
#' ```
18181818
#'
1819-
#' ```{r op_hard_sigmoid-plot}
1819+
#' ```{r op-hard-sigmoid-plot}
18201820
#' x <- as.array(seq(-5, 5, .1))
18211821
#' plot(x, op_hard_sigmoid(x),
18221822
#' type = 'l', panel.first = grid(), frame.plot = FALSE)
@@ -1853,7 +1853,7 @@ keras$ops$hard_sigmoid(x)
18531853
#' op_leaky_relu(x)
18541854
#' # array([-0.2, 0. , 1. ], shape=(3,), dtype=float64)
18551855
#' ```
1856-
#' ```{r op_leaky_relu-plot}
1856+
#' ```{r op-leaky-relu-plot}
18571857
#' x <- seq(-5, 5, .1)
18581858
#' plot(x, op_leaky_relu(x),
18591859
#' type = 'l', panel.first = grid())
@@ -2166,7 +2166,7 @@ function (x, num_classes, axis = -1L, dtype = NULL)
21662166
#' op_relu(x1)
21672167
#' ```
21682168
#'
2169-
#' ```{r op_relu-plot}
2169+
#' ```{r op-relu-plot}
21702170
#' x <- seq(-10, 10, .1)
21712171
#' plot(x, op_relu(x))
21722172
#' ```
@@ -2199,7 +2199,7 @@ keras$ops$relu(x)
21992199
#' x <- op_convert_to_tensor(c(-3, -2, 0.1, 0.2, 6, 8))
22002200
#' op_relu6(x)
22012201
#' ```
2202-
#' ```{r op_relu6-plot}
2202+
#' ```{r op-relu6-plot}
22032203
#' x <- seq(-10, 10, .1)
22042204
#' plot(x, op_relu6(x))
22052205
#' ```
@@ -2439,7 +2439,7 @@ function (x, axis = -1L)
24392439
#' x <- op_convert_to_tensor(c(-0.555, 0, 0.555))
24402440
#' op_softplus(x)
24412441
#' ```
2442-
#' ```{r op_softplus-plot}
2442+
#' ```{r op-softplus-plot}
24432443
#' x <- seq(-10, 10, .1)
24442444
#' plot(x, op_softplus(x))
24452445
#' ```
@@ -2472,7 +2472,7 @@ keras$ops$softplus(x)
24722472
#' x <- op_convert_to_tensor(c(-0.100, -10.0, 1.0, 0.0, 100.0))
24732473
#' op_softsign(x)
24742474
#' ```
2475-
#' ```{r op_softsign-plot}
2475+
#' ```{r op-softsign-plot}
24762476
#' x <- seq(-10, 10, .1)
24772477
#' plot(x, op_softsign(x), ylim = c(-1, 1))
24782478
#' ```

R/reexports.R

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#' @name %>%
66
#' @rdname pipe
77
#' @keywords internal
8+
#' @returns Most commonly, the result of calling the right hand side with the
9+
#' left hand side as an argument: `rhs(lhs)`. See the magritter vignette for
10+
#' other, more advanced, usages.
11+
#' @export
812
#' @export
913
#' @importFrom magrittr %<>% %>%
1014
#' @usage lhs \%>\% rhs
@@ -21,6 +25,8 @@ magrittr::`%<>%`
2125
#' @name %<-%
2226
#' @rdname multi-assign
2327
#' @keywords internal
28+
#' @returns The right-hand-side argument, `value`, invisibly. This called
29+
#' primarily for it's side-effect of assigning symbols in the current frame.
2430
#' @export
2531
#' @importFrom zeallot %<-%
2632
#' @usage x \%<-\% value

docs/articles/getting_started.html

+16-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/news/index.html

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pkgdown.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ articles:
2929
writing_a_custom_training_loop_in_torch: writing_a_custom_training_loop_in_torch.html
3030
writing_a_training_loop_from_scratch: writing_a_training_loop_from_scratch.html
3131
writing_your_own_callbacks: writing_your_own_callbacks.html
32-
last_built: 2024-02-12T15:51Z
32+
last_built: 2024-02-19T13:45Z
3333
urls:
3434
reference: https://keras.posit.co/reference
3535
article: https://keras.posit.co/articles

0 commit comments

Comments
 (0)