PLearn 0.1
InfiniteMNISTVMatrix.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // InfiniteMNISTVMatrix.h
00004 //
00005 // Copyright (C) 2008 Hugo Larochelle
00006 //
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are met:
00009 //
00010 //  1. Redistributions of source code must retain the above copyright
00011 //     notice, this list of conditions and the following disclaimer.
00012 //
00013 //  2. Redistributions in binary form must reproduce the above copyright
00014 //     notice, this list of conditions and the following disclaimer in the
00015 //     documentation and/or other materials provided with the distribution.
00016 //
00017 //  3. The name of the authors may not be used to endorse or promote
00018 //     products derived from this software without specific prior written
00019 //     permission.
00020 //
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 //
00032 // This file is part of the PLearn library. For more information on the PLearn
00033 // library, go to the PLearn Web site at www.plearn.org
00034 
00035 // Authors: Hugo Larochelle
00036 
00040 #ifndef InfiniteMNISTVMatrix_INC
00041 #define InfiniteMNISTVMatrix_INC
00042 
00043 #define TEST_IMAGES_PATH "/home/fringant2/lisa/data/mnist/t10k-images-idx3-ubyte"
00044 #define TEST_LABELS_PATH "/home/fringant2/lisa/data/mnist/t10k-labels-idx1-ubyte"
00045 #define TRAIN_IMAGES_PATH "/home/fringant2/lisa/data/mnist/train-images-idx3-ubyte"
00046 #define TRAIN_LABELS_PATH "/home/fringant2/lisa/data/mnist/train-labels-idx1-ubyte"
00047 #define FIELDS_PATH "/home/fringant2/lisa/data/mnist/fields_float_1522x28x28.bin"
00048 #define TANGVEC_PATH "/home/fringant2/lisa/data/mnist/tangVec_float_60000x28x28.bin"
00049 
00050 #include <plearn/vmat/RowBufferedVMatrix.h>
00051 #include <plearn/math/PRandom.h>
00052 #include <kernel-invariant.h>
00053 //#include "kernel-invariant2.h"
00054 
00055 namespace PLearn {
00056 
00064 class InfiniteMNISTVMatrix : public RowBufferedVMatrix
00065 {
00066     typedef RowBufferedVMatrix inherited;
00067 
00068 public:
00069     //#####  Public Build Options  ############################################
00070 
00074     bool include_test_examples;
00075 
00078     bool include_validation_examples;
00079 
00083     bool random_switch_to_original_training_set;
00084     
00086     real proportion_of_switches;
00087     
00089     int seed;
00090 
00092     real input_divisor;
00093 
00095     PP< PRandom > random_gen;
00096 
00097     // Files required for loading infinite MNIST dataset
00099     string test_images;
00101     string test_labels;
00103     string train_images;
00105     string train_labels;
00107     string fields;
00109     string tangent_vectors;
00110 
00111 public:
00112     //#####  Public Member Functions  #########################################
00113 
00115     // ### Make sure the implementation in the .cc
00116     // ### initializes all fields to reasonable default values.
00117     InfiniteMNISTVMatrix();
00118 
00119     ~InfiniteMNISTVMatrix();
00120 
00121     //#####  PLearn::Object Protocol  #########################################
00122 
00123     // Declares other standard object methods.
00124     // ### If your class is not instantiatable (it has pure virtual methods)
00125     // ### you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS
00126     PLEARN_DECLARE_OBJECT(InfiniteMNISTVMatrix);
00127 
00128     // Simply calls inherited::build() then build_()
00129     virtual void build();
00130 
00132     // (PLEASE IMPLEMENT IN .cc)
00133     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00134 
00135 protected:
00136     //#####  Protected Options  ###############################################
00137 
00138     static mnistproblem_t *dataset;
00139     static int n_pointers_to_dataset;
00140     mutable unsigned char* image;
00141 
00142 protected:
00143     //#####  Protected Member Functions  ######################################
00144 
00146     // (PLEASE IMPLEMENT IN .cc)
00147     static void declareOptions(OptionList& ol);
00148 
00151     // (PLEASE IMPLEMENT IN .cc)
00152     virtual void getNewRow(int i, const Vec& v) const;
00153 
00154 private:
00155     //#####  Private Member Functions  ########################################
00156 
00158     // (PLEASE IMPLEMENT IN .cc)
00159     void build_();
00160 
00161 private:
00162     //#####  Private Data Members  ############################################
00163 
00164     // The rest of the private stuff goes here
00165 };
00166 
00167 // Declares a few other classes and functions related to this class
00168 DECLARE_OBJECT_PTR(InfiniteMNISTVMatrix);
00169 
00170 } // end of namespace PLearn
00171 
00172 #endif
00173 
00174 
00175 /*
00176   Local Variables:
00177   mode:c++
00178   c-basic-offset:4
00179   c-file-style:"stroustrup"
00180   c-file-offsets:((innamespace . 0)(inline-open . 0))
00181   indent-tabs-mode:nil
00182   fill-column:79
00183   End:
00184 */
00185 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines