Open ZheMann opened 4 years ago
This is quite hidden into the code base, but in the case of flow_from_directory, it is a percentage per directory.
Not sure why is that not visible in @Dref360s answer, but important part is last sentence:
split: tuple of floats (e.g. (0.2, 0.6)
) to only take into
account a certain fraction of files in each directory.
E.g.: segment=(0.6, 1.0)
would only account for last 40 percent
of images in each directory.
Actually, files are Python sorted()
and if you format image names properly, you could use this feature pretty easy. Otherwise you might get something like this:
_image_0.jpg image_1.jpg image_10.jpg image_100.jpg image_1000.jpg image_1001.jpg image_1002.jpg image_1003.jpg image_1004.jpg image_1005.jpg image_1006.jpg image_1007.jpg image_1008.jpg image_1009.jpg image_101.jpg image_1010.jpg image_1011.jpg image_1012.jpg image_1013.jpg image_1014.jpg image_1015.jpg image_1016.jpg image_1017.jpg image_1018.jpg image1019.jpg
When setting parameter
validation_split
to a value larger than 0.0, how does the KerasImageDataGenerator
select the validation images? Are they randomly selected from the input directory, or are the lastn
samples used, similar to thevalidation_split
parameter formodel.fit
? More specifically, I'm primarily interested in the following situation: considering theflow_from_directory
method, ashuffle
parameter is available to randomize the data. However, is the shuffle applied after the input directory is splitted into a train and validation set by theImageDataGenerator
, or before?I went through the official Keras and TF pages but they both show the same explanation of
validation_split
, namely:I also went through the source code (both Keras and TF) without any luck of finding additional information.