X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=ann.cc;fp=ann.cc;h=0000000000000000000000000000000000000000;hb=6cf6ebfe5fef7a2f717ce353bd9a2a0c7c2e8bda;hp=758b62422c108f2fe4776091e26315313636bc41;hpb=d952b7b146e7e8b7009915c367ed8e1f2435e14b;p=mlp.git diff --git a/ann.cc b/ann.cc deleted file mode 100644 index 758b624..0000000 --- a/ann.cc +++ /dev/null @@ -1,322 +0,0 @@ -/* - * mlp-mnist is an implementation of a multi-layer neural network. - * - * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, - * http://www.epfl.ch - * - * Written by Francois Fleuret - * - * This file is part of mlp-mnist. - * - * mlp-mnist is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * mlp-mnist is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with mlp-mnist. If not, see . - * - */ - -// LeCun et al. 1998: - -// 2-layer NN, 300 hidden units, mean square error 4.70% -// 2-layer NN, 1000 hidden units 4.50% -// 3-layer NN, 300+100 hidden units 3.05% -// 3-layer NN, 500+150 hidden units 2.95% - -/********************************************************************* - - This program, trained on 20,000 (+ 20,000 for the stopping - criterion), tested on the 10,000 of the MNIST test set 100 hidden - neurons, basic network, 3.48% - - TRAINING - - ./ann --nb-training-examples 20000 --nb-validation-examples 20000 \ - --mlp-structure 784,200,10 \ - --data-files ${DATA_DIR}/train-images-idx3-ubyte ${DATA_DIR}/train-labels-idx1-ubyte \ - --save-mlp simple.mlp - - TEST - - ./ann --load-mlp simple.mlp \ - --data-files ${DATA_DIR}/t10k-images-idx3-ubyte ${DATA_DIR}/t10k-labels-idx1-ubyte \ - --nb-test-examples 10000 - -*********************************************************************/ - -#include -#include -#include -#include -#include -#include - -using namespace std; - -#include "images.h" -#include "neural.h" - -#define SMALL_BUFFER_SIZE 1024 - -////////////////////////////////////////////////////////////////////// -// Global Variables -////////////////////////////////////////////////////////////////////// - -int nb_experiment = 0; -int nb_training_examples = 0; -int nb_validation_examples = 0; -int nb_test_examples = 0; -bool save_data = false; - -char images_filename[SMALL_BUFFER_SIZE] = "\0"; -char labels_filename[SMALL_BUFFER_SIZE] = "\0"; -char opt_load_filename[SMALL_BUFFER_SIZE] = "\0"; -char opt_save_filename[SMALL_BUFFER_SIZE] = "\0"; -char opt_layer_sizes[SMALL_BUFFER_SIZE] = "\0"; - -char *next_word(char *buffer, char *r, int buffer_size) { - char *s; - s = buffer; - if(r != NULL) - { - if(*r == '"') { - r++; - while((*r != '"') && (*r != '\0') && - (s= argc) { - cerr << "Missing argument for " << argv[n_opt] << ".\n"; - cerr << "Expecting " << help << ".\n"; - exit(1); - } -} - -void print_help_and_exit(int e) { - cout << "ANN. Written by François Fleuret.\n"; - cout << "$Id: ann.cc,v 1.1 2005-12-13 17:19:11 fleuret Exp $\n"; - cout<< "\n"; - exit(e); -} - -int main(int argc, char **argv) { - - if(argc == 1) print_help_and_exit(1); - - nice(10); - - // Parsing the command line parameters /////////////////////////////// - - int i = 1; - - while(i < argc) { - - if(argc == 1 || strcmp(argv[i], "--help") == 0) print_help_and_exit(0); - - else if(strcmp(argv[i], "--data-files") == 0) { - check_opt(argc, argv, i, 2, " "); - strncpy(images_filename, argv[i+1], SMALL_BUFFER_SIZE); - strncpy(labels_filename, argv[i+2], SMALL_BUFFER_SIZE); - i += 3; - } - - else if(strcmp(argv[i], "--load-mlp") == 0) { - check_opt(argc, argv, i, 1, ""); - strncpy(opt_load_filename, argv[i+1], SMALL_BUFFER_SIZE); - i += 2; - } - - else if(strcmp(argv[i], "--mlp-structure") == 0) { - check_opt(argc, argv, i, 1, ",