Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

annetwork.h

Go to the documentation of this file.
00001 
00025 #ifndef __INANNA_ANNETWORK_H__
00026 #define __INANNA_ANNETWORK_H__
00027 
00028 #include <magic/mobject.h>
00029 #include <magic/mcoord.h>
00030 #include <magic/mtable.h>
00031 #include <magic/mattribute.h>
00032 #include "inanna/learning.h"
00033 #include "inanna/topology.h"
00034 #include "inanna/neuron.h"
00035 
00036 // External predeclarations
00037 class NeuronInitializer;
00038 class Equalizer;
00039 
00040 // Internal predeclarations
00041 class FreeWeight;
00042 class Connection;
00043 class Neuron;
00044 class ANNetwork;
00045 
00046 
00047 
00049 // |   |                             ___                       o                 //
00050 // |\  |  ___                   _   /   \        _    |   ___      _    ___      //
00051 // | \ | /   ) |   | |/\  __  |/ \  |      __  |/ \  -+-  ___| | |/ \  /   ) |/\ //
00052 // |  \| |---  |   | |   /  \ |   | |     /  \ |   |  |  (   | | |   | |---  |   //
00053 // |   |  \__   \__! |   \__/ |   | \___/ \__/ |   |   \  \__| | |   |  \__  |   //
00055 
00056 
00057 // We are so f*cking free that all this f*cking freedom restricts our
00058 // f*cking lives so f*cking much
00059 
00064 class NeuronContainer : public Array<Neuron> {
00065     decl_dynamic (NeuronContainer);
00066   public:
00067                         NeuronContainer     () : mUnits (*this) {}
00068                         NeuronContainer     (int size) : Array<Neuron> (size), mUnits (*this) {}
00069                         ~NeuronContainer    ();
00070 
00071     //void              makeNeurons     (int size) {make (size);}
00072 
00078     void                add             (Neuron* neuron);
00079 
00082     void                removeUnit      (int i);
00083 
00085     //void              writeXML        (OStream& out) const;
00086 
00087   private:
00088     void                disconnectAll   ();
00089     
00090   protected:
00092     Array<Neuron>&  mUnits;
00093 };
00094 
00095 
00096 
00098 //                                                                           //
00099 //                _   |   | |   |                           |                //
00100 //               / \  |\  | |\  |  ___   |                  |                //
00101 //              /   \ | \ | | \ | /   ) -+- \    /  __  |/\ | /              //
00102 //              |---| |  \| |  \| |---   |   \\//  /  \ |   |/               //
00103 //              |   | |   | |   |  \__    \   VV   \__/ |   | \              //
00104 //                                                                           //
00106 
00109 class ANNetwork : public NeuronContainer, virtual public Learner, public Attributed {
00110     decl_dynamic (ANNetwork);
00111   public:
00112 
00113                         ANNetwork       (const char* description=NULL);
00114                         ANNetwork       (const ANNetwork& orig) {copy (orig);}
00115     virtual             ~ANNetwork  ();
00116 
00123     void                makeUnits       (const char* topology);
00124 
00129     virtual void        make            (const char* top) {makeUnits(top);}
00130 
00132     virtual void        empty           ();
00133 
00135     virtual void        copy            (const ANNetwork& fnet, bool onlyWeights=false);
00136 
00140     void                connectFfw      (const PackTable<int>& conns);
00141 
00145     void                connectFullFfw  (bool shortcuts);
00146 
00149     void                connectFull     ();
00150 
00157     void                setUnitPrototype    (Neuron* t) {delete mUnitTemplate; mUnitTemplate=t;}
00158     const Neuron    *   getUnitPrototype    () const {return mUnitTemplate;}
00159 
00162     virtual void        copyFreeNet     (const ANNetwork& orig, bool onlyWeights=false);
00163 
00168     virtual void        init            (double r=0.0);
00169 
00171     void                reset           ();
00172 
00174     virtual void        update   ();
00175 
00177     virtual Vector      testPattern     (const PatternSource& set, int pattern) const;
00178 
00180     const ANNTopology&  getTopology     () const {return *mTopology;}
00181     //const ANNLayering&    getLayering     () const {return *mTopology;}
00182 
00186     void                setInitializer  (NeuronInitializer* initer);    
00187 
00191     Equalizer*          getEqualizer    () {return mpEqualizer;}
00192 
00196     const Equalizer*    getEqualizer    () const {return mpEqualizer;}
00197 
00199     void                setEqualizer    (Equalizer* eq=NULL);
00200 
00201     // Tools
00202 
00204     Connection*         connect         (int i, int j);
00205 
00209     virtual OStream&    operator>>		(OStream& out) const;
00210 
00219     void                cleanup         (bool removeDisableds=false,
00220                                          bool removePassthroughs=false);
00221 
00228     String              drawEPS         (double xsize=-1, double ysize=-1) const;
00229 
00234     void                drawFeedForward ();
00235 
00237     void                check           () const;
00238     
00239   protected:
00241     ANNTopology*        mTopology;
00242 
00244     Neuron*             mUnitTemplate;
00245 
00247     NeuronInitializer*  mInitializer;
00248 
00250     Equalizer*          mpEqualizer;
00251 
00252   private:
00254     void                orderColumn     (int colStart, int colEnd);
00255 
00256     void operator= (const ANNetwork& other) {FORBIDDEN} // Prevent
00257 };
00258 
00259 // "Man is truly free only when man truly dies" -- Prince
00260 
00261 #endif
00262 
00263 

Generated on Thu Feb 10 20:06:44 2005 for Inanna by doxygen1.2.18