/* @(#)learn.h 1.3 12/9/92 */ /* * file : learn.h * * * Andrew H. Fagg * Center for Neural Engineering * Computer Science Department * University of Southern California * Henry Salvatori #300 * Los Angeles, CA 90089-0781 * * ahfagg@pollux.usc.edu * * * HISTORY * Date Author Description * -------- ----------------- -------------------------------- * 12/05/92 Andrew H. Fagg Doc update. * 01/15/92 Andrew H. Fagg Original. * */ #define LEFT 0 #define RIGHT 1 #define DOWN 2 #define LIMITED_ACTIVITY_FLAG /*#define LIMITED_VOTING_ACTIVITY_FLAG */ #define LINEAR 0 #define BINARY 1 #define COMPRESSED_LINEAR 2 #define JUMP_LINEAR 3 #define NO_GO_CASE 0 extern double drand48(); extern void srand48(long); class Feature : public NslModule { public: NslDinInt1 inputs; NslDinFloat1 voting_contribution; /* Output of voting units. */ NslDinFloat0 threshold_v; NslDinFloat0 factor; NslDoutFloat1 feature; /* Firing rate. */ private: NslFloat1 feature_mem; /* Membrane potential. */ NslFloat0 threshold_f; /* Threshold */ NslFloat0 u_feature; /* Integration time constant. */ NslFloat0 lrate_f; /* Feature. */ NslFloat1 inputsf; // used for display purposes NslFloat2 w_in_feature; NslFloat2 dw_in_feature; NslFloat2 w_in_feature_mask; NslFloat0 input_weight_bias; /* Constant value added to initial weights. */ NslFloat0 w_in_feature_probability; /* Probability of connection*/ NslFloat0 L1_norm_mode; /* Type of normalization applied to weights. */ NslFloat0 negative_factor_f; /* Scale factor for receiving negative */ /* reinforcement */ public: Feature(nsl_string,NslModule*); ~Feature() {} void memAlloc(int,int); void initSys(); void initTrain(); void simTrain(); void endTrain(); }; class Noise : public nsl_model // AslSchema { public: NslFloat1 noise; NslFloat0 gain; NslFloat0 change_probability; public: Noise(nsl_string,nsl_model*); ~Noise() {} void memAlloc(int); void initExec(); void simExec(); }; class Vote : public NslModule { public: Noise noise; NslDinFloat0 threshold_v; NslDinFloat1 feature; NslDoutFloat1 voting; NslDoutFloat1 voting_contribution; /* Output of voting units. */ private: NslFloat1 voting_mem; NslFloat0 u_voting; NslInt0 voting_contribution_mode; /* Mapping from voting unit activity to */ /* voting unit output. */ NslFloat0 voting_contribution_scale; /* Used for some types of mappings. */ NslInt0 display_participation_mode; /* If = 1, then display the participation */ /* vector at the end of each trial. */ NslInt1 voting_participation; /* Binary pattern of which */ /* columns are active */ NslFloat0 init_threshold_v; int _num_columns; public: Vote(nsl_string,NslModule*); ~Vote() {} void memAlloc(int); void initSys(); void initTrain(); void simTrain(); void endTrain(); }; class Threshold : public NslModule { public: NslDinFloat0 s; NslDoutFloat0 threshold_v; /* Threshold (varying over time) */ private: NslFloat0 u_threshold_v;/* Time constant of threshold change. */ NslFloat0 init_threshold_v; public: Threshold(nsl_string,NslModule*); ~Threshold() {} void initTrain(); void simTrain(); }; class Motor : public NslModule { public: Noise noise; NslDinFloat1 voting; NslDinFloat1 voting_contribution; NslDinFloat0 s; NslDinFloat0 factor; NslDoutFloat1 motor; NslDoutInt0 above_thresh_num; NslDoutInt0 stable_num; NslDoutInt0 winner; private: NslFloat1 dmotor_mem; NslFloat1 motor_mem; NslFloat1 motor_inputs; NslFloat0 u_motor; NslFloat0 threshold_m; NslFloat2 w_vote_motor; NslFloat2 dw_vote_motor; NslFloat2 w_vote_motor_mask; NslFloat0 voting_weight_bias; NslFloat0 w_vote_motor_probability; NslFloat0 voting_factor; /* Scales input activity from voting units. */ NslFloat0 lrate_v; /* Voting. */ NslFloat0 L1_norm_mode; /* Type of normalization applied to weights. */ NslFloat0 normalize_input_mode; /* Determines if W_vote_motor is input */ /* or output normailized. */ NslFloat0 stable_detect_threshold; /* Changes in activity must be less than */ /* threshold for equilibrium to be reached. */ int _num_columns,_num_choices; public: Motor(nsl_string,NslModule*); ~Motor() {} void memAlloc(int,int); void initSys(); void initTrain(); void simTrain(); void endTrain(); }; // S-Compute class WTA : public NslModule { public: NslDinFloat1 motor; NslDoutFloat0 s; private: NslFloat0 s_mem; NslFloat0 u_s; NslFloat0 threshold_s; public: WTA(nsl_string,NslModule*); ~WTA() {} void memAlloc(int); void initTrain(); void simTrain(); }; class CondLearn : public NslModule { private: Feature feature; Threshold threshold; Vote vote; Motor motor; WTA wta; public: NslDinInt0 inpat; // Current input pattern NslDinInt1 input; NslDinInt0 output; NslDoutInt0 new_read; // if 1 read new input NslDoutFloat0 factor; NslDinInt0 above_thresh_num; NslDinInt0 stable_num; NslDinInt0 winner; NslDinFloat1 voting; private: NslInt0 collect; int collect_mode; /* 0, if 1, collecting statistics. */ int timer_flag; /* On completion, set to 1 if at least */ /* 1 MPSU is active, -1 if none. */ NslFloat0 display_set_unit_flag; /* If true, then display set unit activation. */ NslFloat0 first_pole_mode; /* Winner-take-all parameter */ NslFloat0 normalize_input_mode; /* Determines if W_vote_motor is input */ /* or output normailized. */ NslFloat0 special_punish_mode; /* If no MPSUs are active at time of */ /* punishment, then reward to get voting */ /* activity up. */ NslInt0 seed; int _num_columns,_num_choices; public: CondLearn(char*,NslModule*); ~CondLearn() {} void memAlloc(int,int,int); void initSys(); void initTrain(); void simTrain(); void endTrain(); void punish_reward_func(int); }; class TrainFile : public NslModule { public: NslDinInt0 new_read; // if 1 read new input NslDoutInt1 input; // Current vector of inputs NslDoutInt0 output; // Current output NslDoutInt0 inpat; // Current input pattern private: NslStr0 pName; NslInt2 pInput; int current_pat; NslInt1 pOutput; // Set of expected outputs. int patterns_loaded_flag; NslInt0 inSize; NslInt0 outSize; NslInt0 numPats; NslInt0 repeat; int repeat_mode; /* 0, if 1, repeat trial */ // nsl_file f; public: TrainFile(char*,NslModule*); ~TrainFile() {} // int memAlloc(int,int); void readFile(); void initTrain(); }; class CondLearnModel : public NslModel { public: TrainFile tf; CondLearn cl; public: CondLearnModel(); ~CondLearnModel() {} void makeConn(); void initSys(); };