@@ -226,12 +226,13 @@ function TinyImageTo1D(var TI: TTinySingleChannelImage): TTinySingleChannelImage
226
226
227
227
// creates CIFAR10 volumes required for training, testing and validation
228
228
procedure CreateCifar10Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
229
- ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB);
229
+ ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
230
+ ValidationSampleSize: integer = 2000 );
230
231
231
232
// creates CIFAR100 volumes required for training, testing and validation
232
233
procedure CreateCifar100Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
233
234
ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
234
- Verbose:boolean = true);
235
+ Verbose:boolean = true; ValidationSampleSize: integer = 2000 );
235
236
236
237
// creates MNIST volumes required for training, testing and validation
237
238
procedure CreateMNISTVolumes (out ImgTrainingVolumes, ImgValidationVolumes,
@@ -831,14 +832,17 @@ procedure TranslateCifar10VolumesToMachineAnimal(VolumeList: TNNetVolumeList);
831
832
end ;
832
833
833
834
procedure CreateCifar10Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
834
- ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB);
835
+ ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
836
+ ValidationSampleSize: integer = 2000 );
835
837
var
836
- I: integer;
838
+ I, LastElement : integer;
837
839
begin
838
840
ImgTrainingVolumes := TNNetVolumeList.Create();
839
841
ImgValidationVolumes := TNNetVolumeList.Create();
840
842
ImgTestVolumes := TNNetVolumeList.Create();
841
843
844
+ if ValidationSampleSize > 10000 then ValidationSampleSize := 10000 ;
845
+
842
846
// creates required volumes to store images
843
847
for I := 0 to 39999 do
844
848
begin
@@ -857,28 +861,44 @@ procedure CreateCifar10Volumes(out ImgTrainingVolumes, ImgValidationVolumes,
857
861
loadCifar10Dataset(ImgTrainingVolumes, 4 , 30000 , color_encoding);
858
862
loadCifar10Dataset(ImgValidationVolumes, 5 , 0 , color_encoding);
859
863
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 ;
860
877
end ;
861
878
862
879
procedure CreateCifar100Volumes (out ImgTrainingVolumes, ImgValidationVolumes,
863
880
ImgTestVolumes: TNNetVolumeList; color_encoding: byte = csEncodeRGB;
864
- Verbose:boolean = true);
881
+ Verbose:boolean = true; ValidationSampleSize: integer = 2000 );
865
882
var
866
883
I, LastElement: integer;
867
884
begin
868
885
ImgTrainingVolumes := TNNetVolumeList.Create();
869
- ImgTrainingVolumes.FreeObjects := false;
870
886
ImgValidationVolumes := TNNetVolumeList.Create();
871
887
ImgTestVolumes := TNNetVolumeList.Create();
872
888
loadCifar100Dataset(ImgTrainingVolumes, ' train.bin' , color_encoding, Verbose);
873
889
loadCifar100Dataset(ImgTestVolumes, ' test.bin' , color_encoding, Verbose);
874
-
875
890
LastElement := ImgTrainingVolumes.Count - 1 ;
876
- for I := LastElement downto (LastElement- 4999 ) do
891
+ if ValidationSampleSize > 0 then
877
892
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;
880
901
end ;
881
- ImgTrainingVolumes.FreeObjects := true;
882
902
end ;
883
903
884
904
procedure CreateMNISTVolumes (out ImgTrainingVolumes, ImgValidationVolumes,
0 commit comments