Skip to contents

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