unpack_x_y_sample_weight: Unpacks user-provided data list.

unpack_x_y_sample_weightR Documentation

Unpacks user-provided data list.

Description

This is a convenience utility to be used when overriding ⁠$train_step⁠, ⁠$test_step⁠, or ⁠$predict_step⁠. This utility makes it easy to support data of the form ⁠(x,)⁠, ⁠(x, y)⁠, or ⁠(x, y, sample_weight)⁠.

Usage

unpack_x_y_sample_weight(data)

Arguments

data

A list of the form (x), ⁠(x, y)⁠, or ⁠(x, y, sample_weight)⁠.

Value

The unpacked list, with NULLs for y and sample_weight if they are not provided.

Example:

features_batch <- op_ones(c(10, 5))
labels_batch <- op_zeros(c(10, 5))
data <- list(features_batch, labels_batch)
# `y` and `sample_weight` will default to `NULL` if not provided.
c(x, y, sample_weight) %<-% unpack_x_y_sample_weight(data)

You can also do the equivalent by providing default values to ⁠%<-%⁠

c(x, y = NULL, sample_weight = NULL) %<-% data

See Also

Other data utils:
pack_x_y_sample_weight()
zip_lists()

Other utils:
audio_dataset_from_directory()
clear_session()
config_disable_interactive_logging()
config_disable_traceback_filtering()
config_enable_interactive_logging()
config_enable_traceback_filtering()
config_is_interactive_logging_enabled()
config_is_traceback_filtering_enabled()
get_file()
get_source_inputs()
image_array_save()
image_dataset_from_directory()
image_from_array()
image_load()
image_smart_resize()
image_to_array()
layer_feature_space()
normalize()
pack_x_y_sample_weight()
pad_sequences()
set_random_seed()
split_dataset()
text_dataset_from_directory()
timeseries_dataset_from_array()
to_categorical()
zip_lists()


rstudio/keras documentation built on April 27, 2024, 10:11 p.m.