Skip to content

Commit 20fee76

Browse files
authored
Merge pull request #1353 from terrytangyuan/subset-both
Support subset=both in image_dataset_from_directory()
2 parents b778be2 + 086fd38 commit 20fee76

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

R/preprocessing.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,9 @@ flow_images_from_dataframe <- function(
10301030
#' @param seed Optional random seed for shuffling and transformations.
10311031
#' @param validation_split Optional float between 0 and 1, fraction of data to
10321032
#' reserve for validation.
1033-
#' @param subset One of "training" or "validation". Only used if
1034-
#' validation_split is set.
1033+
#' @param subset One of "training", "validation", or "both" (available for TF>=2.10).
1034+
#' Only used if validation_split is set. When `subset="both"`, the utility returns
1035+
#' a tuple of two datasets (the training and validation datasets respectively).
10351036
#' @param interpolation String, the interpolation method used when resizing
10361037
#' images. Defaults to bilinear. Supports bilinear, nearest, bicubic, area,
10371038
#' lanczos3, lanczos5, gaussian, mitchellcubic.
@@ -1101,6 +1102,10 @@ image_dataset_from_directory <- function(
11011102
seed = as_nullable_integer,
11021103
labels = function(l) if(is.character(l)) l else as.integer(l)
11031104
))
1105+
1106+
if (tensorflow::tf_version() < "2.10" && subset == "both") {
1107+
stop('subset="both" is only available for TF>=2.10')
1108+
}
11041109

11051110
out <- do.call(keras$preprocessing$image_dataset_from_directory, args)
11061111
class(out) <- unique(c("tf_dataset", class(out)))

man/image_dataset_from_directory.Rd

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

man/install_keras.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.

man/keras.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)