R/class_keras.R

Defines functions store_get_packages.tar_keras store_unmarshal_object.tar_keras store_marshal_object.tar_keras store_write_path.tar_keras store_read_path.tar_keras store_assert_format_setting.keras store_class_format.keras

#' @export
store_class_format.keras <- function(format) {
  c("tar_keras", "tar_nonexportable", "tar_store")
}

#' @export
store_assert_format_setting.keras <- function(format) {
}

# It would be too burdensome to depend on Python Keras
# just for automated testing, so this code is covered
# in semi-automated tests in tests/hpc/ and # nolint
# tests/interactive/. # nolint
# nocov start
#' @export
store_read_path.tar_keras <- function(store, path) {
  keras::load_model_hdf5(path)
}

#' @export
store_write_path.tar_keras <- function(store, object, path) {
  keras::save_model_hdf5(object = object, filepath = path)
}

#' @export
store_marshal_object.tar_keras <- function(store, object) {
  keras::serialize_model(object)
}

#' @export
store_unmarshal_object.tar_keras <- function(store, object) {
  keras::unserialize_model(object)
}
# nocov end

#' @export
store_get_packages.tar_keras <- function(store) {
  "keras"
}

Try the targets package in your browser

Any scripts or data that you put into this service are public.

targets documentation built on Oct. 12, 2023, 5:07 p.m.