Skip to content

Commit 9cbbb0b

Browse files
committed
Updating documentation
1 parent 8255647 commit 9cbbb0b

25 files changed

+49
-29
lines changed

R/compile_keras_grid.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
#' }
4141
#'
4242
#' @examples
43-
#' \dontrun{
44-
#' if (keras::is_keras_available()) {
43+
#' \donttest{
44+
#' if (requireNamespace("keras3", quietly = TRUE)) {
4545
#'
4646
#' # 1. Define a kerasnip model specification
4747
#' create_keras_sequential_spec(
@@ -193,7 +193,7 @@ compile_keras_grid <- function(spec, grid, x, y) {
193193
#' are removed, leaving a clean grid ready for tuning.
194194
#'
195195
#' @examples
196-
#' \dontrun{
196+
#' \donttest{
197197
#' # Continuing the example from `compile_keras_grid`:
198198
#'
199199
#' # `compiled_grid` contains one row with an error.
@@ -241,7 +241,7 @@ extract_valid_grid <- function(compiled_grid) {
241241
#' effect of printing a summary to the console.
242242
#'
243243
#' @examples
244-
#' \dontrun{
244+
#' \donttest{
245245
#' # Continuing the example from `compile_keras_grid`:
246246
#'
247247
#' # `compiled_grid` contains one row with an error.

R/create_keras_functional_spec.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
#'
7373
#' @export
7474
#' @examples
75-
#' \dontrun{
75+
#' \donttest{
7676
#' if (requireNamespace("keras3", quietly = TRUE)) {
7777
#' library(keras3)
7878
#' library(parsnip)

R/create_keras_sequential_spec.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#'
6262
#' @export
6363
#' @examples
64-
#' \dontrun{
64+
#' \donttest{
6565
#' if (requireNamespace("keras3", quietly = TRUE)) {
6666
#' library(keras3)
6767
#' library(parsnip)

R/create_keras_spec_helpers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ collect_spec_args <- function(
140140
#'
141141
#' @export
142142
#' @examples
143-
#' \dontrun{
143+
#' \donttest{
144144
#' # --- Example Blocks ---
145145
#' # A standard dense block with one input tensor and one hyperparameter.
146146
#' dense_block <- function(tensor, units = 16) {

R/generic_functional_fit.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#' # This function is not called directly by users.
5757
#' # It is called internally by `parsnip::fit()`.
5858
#' # For example:
59-
#' \dontrun{
59+
#' \donttest{
6060
#' # create_keras_functional_spec(...) defines my_functional_model
6161
#'
6262
#' spec <- my_functional_model(hidden_units = 128, fit_epochs = 10) |>

R/generic_sequential_fit.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#' # This function is not called directly by users.
5757
#' # It is called internally by `parsnip::fit()`.
5858
#' # For example:
59-
#' \dontrun{
59+
#' \donttest{
6060
#' # create_keras_sequential_spec(...) defines my_sequential_model
6161
#'
6262
#' spec <- my_sequential_model(hidden_1_units = 128, fit_epochs = 10) |>

R/keras_tools.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#' with.
1919
#'
2020
#' @examples
21-
#' \dontrun{
22-
#' if (keras::is_keras_available()) {
21+
#' \donttest{
22+
#' if (requireNamespace("keras3", quietly = TRUE)) {
2323
#'
2424
#' # 1. Define and fit a model ----
2525
#' create_keras_sequential_spec(
@@ -135,4 +135,4 @@ extract_keras_model <- function(object) {
135135
#' @export
136136
extract_keras_history <- function(object) {
137137
object$fit$history
138-
}
138+
}

R/remove_keras_spec.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#' @seealso [create_keras_sequential_spec()], [create_keras_functional_spec()]
2929
#' @export
3030
#' @examples
31-
#' \dontrun{
31+
#' \donttest{
3232
#' if (requireNamespace("keras3", quietly = TRUE)) {
3333
#' # First, create a dummy spec
3434
#' input_block <- function(model, input_shape) {

R/utils.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#' optimizer object.
3030
#' @seealso [register_keras_loss()], [register_keras_metric()]
3131
#' @export
32+
#' @return No return value, called for side effects.
3233
#' @examples
3334
#' if (requireNamespace("keras3", quietly = TRUE)) {
3435
#' # Register a custom version of Adam with a different default beta_1
@@ -58,6 +59,7 @@ register_keras_optimizer <- function(name, optimizer_fn) {
5859
#' @param loss_fn The loss function.
5960
#' @seealso [register_keras_optimizer()], [register_keras_metric()]
6061
#' @export
62+
#' @return No return value, called for side effects.
6163
register_keras_loss <- function(name, loss_fn) {
6264
.kerasnip_custom_objects$losses[[name]] <- loss_fn
6365
invisible()
@@ -78,6 +80,7 @@ register_keras_loss <- function(name, loss_fn) {
7880
#' @param metric_fn The metric function.
7981
#' @seealso [register_keras_optimizer()], [register_keras_loss()]
8082
#' @export
83+
#' @return No return value, called for side effects.
8184
register_keras_metric <- function(name, metric_fn) {
8285
.kerasnip_custom_objects$metrics[[name]] <- metric_fn
8386
invisible()
@@ -144,6 +147,7 @@ get_keras_object <- function(
144147
#' known optimizers (keras defaults + custom registered).
145148
#' @keywords internal
146149
#' @export
150+
#' @return A `dials` parameter object for Keras optimizers.
147151
optimizer_function <- function(values = NULL) {
148152
if (is.null(values)) {
149153
values <- unique(c(
@@ -164,6 +168,7 @@ optimizer_function <- function(values = NULL) {
164168
#' known losses (keras defaults + custom registered).
165169
#' @keywords internal
166170
#' @export
171+
#' @return A `dials` parameter object for Keras loss.
167172
loss_function_keras <- function(values = NULL) {
168173
if (is.null(values)) {
169174
values <- unique(c(keras_losses, names(.kerasnip_custom_objects$losses)))
@@ -402,8 +407,8 @@ process_y_sequential <- function(
402407
#'
403408
#' @return The `parsnip` model environment.
404409
#' @examples
405-
#' \dontrun{
406-
#' model_env <- kerasnip:::get_model_env()
410+
#' \donttest{
411+
#' model_env <- kerasnip::get_model_env()
407412
#' }
408413
#' @keywords internal
409414
#' @export

man/compile_keras_grid.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)