Skip to content

Commit 6e97de5

Browse files
committed
Adding extract tools for summary and history
1 parent f45d5f3 commit 6e97de5

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
export(create_keras_functional_spec)
44
export(create_keras_sequential_spec)
5+
export(extract_keras_history)
6+
export(extract_keras_summary)
57
export(generic_functional_fit)
68
export(generic_sequential_fit)
79
export(inp_spec)

R/keras_tools.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,29 @@ keras_evaluate <- function(object, x, y = NULL, ...) {
3232
keras_model <- object$fit$fit
3333
keras3::evaluate(keras_model, x = x_proc, y = y_proc, ...)
3434
}
35+
36+
#' Extract Keras Model Summary
37+
#'
38+
#' @description
39+
#' Extracts and returns the summary of a Keras model fitted with `kerasnip`.
40+
#'
41+
#' @param object A `model_fit` object produced by a `kerasnip` specification.
42+
#' @param ... Additional arguments passed on to `keras3::summary()`.
43+
#'
44+
#' @return A character vector, where each element is a line of the model summary.
45+
#' @export
46+
extract_keras_summary <- function(object, ...) {
47+
object$fit$fit
48+
}
49+
50+
#' Extract Keras Training History
51+
#'
52+
#' @description
53+
#' Extracts and returns the training history of a Keras model fitted with `kerasnip`.
54+
#'
55+
#' @param object A `model_fit` object produced by a `kerasnip` specification.
56+
#' @return A `keras_training_history` containing the training history (metrics per epoch).
57+
#' @export
58+
extract_keras_history <- function(object) {
59+
object$fit$history
60+
}

man/extract_keras_history.Rd

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

man/extract_keras_summary.Rd

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

0 commit comments

Comments
 (0)