/*
* mlp-mnist is an implementation of a multi-layer neural network.
*
- * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
- * Written by Francois Fleuret <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*
return m;
}
-void ImageSet::extract_unused_pictures(ImageSet &is, int nb) {
- if(nb > is.nb_unused_pictures()) {
- cerr << "Trying to extract " << nb << " pictures from a set of " << is.nb_unused_pictures() << "\n";
- exit(1);
- }
-
- _nb_pics = nb;
- _width = is._width;
- _height = is._height;
- _nb_obj = is._nb_obj;
- _pixel_maps = is._pixel_maps->add_ref();
- _pixels = new unsigned char *[_nb_pics];
- _labels = new unsigned char[_nb_pics];
- _used_picture = new bool[_nb_pics];
- for(int n = 0; n < _nb_pics; n++) {
- int m = is.pick_unused_picture();
- _pixels[n] = is._pixels[m];
- _labels[n] = is._labels[m];
- }
-
- reset_used_pictures();
-}
-
void ImageSet::load_mnist_format(char *picture_file_name, char *label_file_name) {
unsigned int magic;
reset_used_pictures();
}
+
+void ImageSet::sample_among_unused_pictures(ImageSet &is, int nb) {
+ if(nb > is.nb_unused_pictures()) {
+ cerr << "Trying to extract " << nb << " pictures from a set of " << is.nb_unused_pictures() << "\n";
+ exit(1);
+ }
+
+ _nb_pics = nb;
+ _width = is._width;
+ _height = is._height;
+ _nb_obj = is._nb_obj;
+ _pixel_maps = is._pixel_maps->add_ref();
+ _pixels = new unsigned char *[_nb_pics];
+ _labels = new unsigned char[_nb_pics];
+ _used_picture = new bool[_nb_pics];
+ for(int n = 0; n < _nb_pics; n++) {
+ int m = is.pick_unused_picture();
+ _pixels[n] = is._pixels[m];
+ _labels[n] = is._labels[m];
+ }
+
+ reset_used_pictures();
+}