@@ -226,12 +226,13 @@ function TinyImageTo1D(var TI: TTinySingleChannelImage): TTinySingleChannelImage
226226
227227// creates CIFAR10 volumes required for training, testing and validation
228228procedure CreateCifar10Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
229- ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB);
229+ ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
230+ ValidationSampleSize: integer = 2000 );
230231
231232// creates CIFAR100 volumes required for training, testing and validation
232233procedure CreateCifar100Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
233234 ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
234- Verbose:boolean = true);
235+ Verbose:boolean = true; ValidationSampleSize: integer = 2000 );
235236
236237// creates MNIST volumes required for training, testing and validation
237238procedure CreateMNISTVolumes (out ImgTrainingVolumes, ImgValidationVolumes,
@@ -831,14 +832,17 @@ procedure TranslateCifar10VolumesToMachineAnimal(VolumeList: TNNetVolumeList);
831832end ;
832833
833834procedure CreateCifar10Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
834- ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB);
835+ ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
836+ ValidationSampleSize: integer = 2000 );
835837var
836- I: integer;
838+ I, LastElement : integer;
837839begin
838840 ImgTrainingVolumes := TNNetVolumeList.Create();
839841 ImgValidationVolumes := TNNetVolumeList.Create();
840842 ImgTestVolumes := TNNetVolumeList.Create();
841843
844+ if ValidationSampleSize > 10000 then ValidationSampleSize := 10000 ;
845+
842846 // creates required volumes to store images
843847 for I := 0 to 39999 do
844848 begin
@@ -857,28 +861,44 @@ procedure CreateCifar10Volumes(out ImgTrainingVolumes, ImgValidationVolumes,
857861 loadCifar10Dataset(ImgTrainingVolumes, 4 , 30000 , color_encoding);
858862 loadCifar10Dataset(ImgValidationVolumes, 5 , 0 , color_encoding);
859863 loadCifar10Dataset(ImgTestVolumes, ' test_batch.bin' , 0 , color_encoding);
864+
865+ // Should move validation volumes to training volumes?
866+ if ValidationSampleSize < 10000 then
867+ begin
868+ ImgValidationVolumes.FreeObjects := False;
869+ LastElement := ImgValidationVolumes.Count - 1 ;
870+ for I := LastElement downto (LastElement-(10000 -ValidationSampleSize)+1 ) do
871+ begin
872+ ImgTrainingVolumes.Add(ImgValidationVolumes[I]);
873+ ImgValidationVolumes.Delete(I);
874+ end ;
875+ ImgValidationVolumes.FreeObjects := True;
876+ end ;
860877end ;
861878
862879procedure CreateCifar100Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
863880 ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
864- Verbose:boolean = true);
881+ Verbose:boolean = true; ValidationSampleSize: integer = 2000 );
865882var
866883 I, LastElement: integer;
867884begin
868885 ImgTrainingVolumes := TNNetVolumeList.Create();
869- ImgTrainingVolumes.FreeObjects := false;
870886 ImgValidationVolumes := TNNetVolumeList.Create();
871887 ImgTestVolumes := TNNetVolumeList.Create();
872888 loadCifar100Dataset(ImgTrainingVolumes, ' train.bin' , color_encoding, Verbose);
873889 loadCifar100Dataset(ImgTestVolumes, ' test.bin' , color_encoding, Verbose);
874-
875890 LastElement := ImgTrainingVolumes.Count - 1 ;
876- for I := LastElement downto (LastElement- 4999 ) do
891+ if ValidationSampleSize > 0 then
877892 begin
878- ImgValidationVolumes.Add(ImgTrainingVolumes[I]);
879- ImgTrainingVolumes.Delete(I);
893+ ImgTrainingVolumes.FreeObjects := false;
894+ if ValidationSampleSize > 25000 then ValidationSampleSize := 25000 ;
895+ for I := LastElement downto (LastElement-ValidationSampleSize+1 ) do
896+ begin
897+ ImgValidationVolumes.Add(ImgTrainingVolumes[I]);
898+ ImgTrainingVolumes.Delete(I);
899+ end ;
900+ ImgTrainingVolumes.FreeObjects := true;
880901 end ;
881- ImgTrainingVolumes.FreeObjects := true;
882902end ;
883903
884904procedure CreateMNISTVolumes (out ImgTrainingVolumes, ImgValidationVolumes,
0 commit comments