AbstractIAFController::AbstractIAFController(const AbstractIAFControllerConf& conf)
    : AbstractController("AbstractIAFController", "$Id$"), conf(conf), range(1.0) {
      addParameter("leaki", conf.leakI);
      addParameter("leako", conf.leakO);
      addParameter("thresholdi", conf.thresholdI);
      addParameter("thresholdo", conf.thresholdO);
      addParameter("wiinitscale", conf.wIInitScale);
      addParameter("wiinitscale", conf.wOInitScale);
      addParameter("niafperinput", conf.numberIAFNeuronsPerInput);
      addParameter("niafperoutput", conf.numberIAFNeuronsPerOutput);
//       addInspectableValue("[I]leak", conf.leakI);
//       addInspectableValue("[O]leak", conf.leakO);
//       addInspectableValue("[I]t",conf.thresholdI);
//       addInspectableValue("[O]t",conf.thresholdO);
      addInspectableMatrix("[I]sum",&sumI);
      addInspectableMatrix("[O]sum",&sumO);
//       addInspectableMatrix("[I]W",&wI);
//       addInspectableMatrix("[O]W",&wO);
      addInspectableMatrix("[I]x",&xI);
      addInspectableMatrix("[O]x",&xO);
      initialised = false;
    }
Exemple #2
0
CuriosityLoop::CuriosityLoop(int inputSize, int motornumber, int sensornumber, int trial_length){
	cout << "Making curiosity loop  of input size " << inputSize << "\n";

	   predictorWeights.set(inputSize+1,inputSize+1); // initialized 0
	   predictorWeights=predictorWeights.map(random_minusone_to_one)*1.0;

//	   predictorMask.set(inputSize+1,inputSize+1);
//
//	   for(int i = 0; i < predictorMask.getM(); i++){
//		for(int j = 0; j < predictorMask.getN(); j++){
//			if(rand()/(RAND_MAX*1.0) < 0.01)
//				predictorMask.val(i,j) = 1;
//			else
//				predictorMask.val(i,j) = 0;
//		}
//	   }

        prediction.set(inputSize+1, 1);

        pInput.set(inputSize+1,1); 
	pOutput.set(inputSize+1,1); 

//	Standard predictors 
/*
	for(int i = 0; i < inputSize+1; i++){ 
	 		if(rand()/(RAND_MAX*1.0) < 0.2)
				pInput.val(i,0) = 1;
			else
				pInput.val(i,0) = 0;

			if(rand()/(RAND_MAX*1.0) < 0.2)
				pOutput.val(i,0) = 1;
			else
				pOutput.val(i,0) = 0;

	};
*/

	//For granger predictors the sensory input should be the last time step of the the sensory output and only sensor states serve as input and output. 

	for(int i = 0; i < inputSize+1; i++){ 
	  pInput.val(i,0) = 0;
	  pOutput.val(i,0) = 0;
 	  if(i < sensornumber+1) { 
	//if( i == 1){ 
	//Handdesigned joint angle to predict. 
	//		        pInput.val(i,0) = 1;
	//			pOutput.val(i,0) = 1;
		
			if(rand()/(RAND_MAX*1.0) < 0.3){
				pInput.val(i,0) = 1;
				pOutput.val(i,0) = 1;
			}
			else{
				pInput.val(i,0) = 0;
				pOutput.val(i,0) = 0;
			}

	  }
	}


	uPredictorWeights = predictorWeights;  
 	//uPredictorMask = predictorMask; 
        uPrediction = prediction;   
	
	uPInput = pInput; 
	uPOutput = pOutput; 
	
	//Unrestrict upInput now to it gets input from all motors (of the actor) and the sensors of the restricted model.  
	for(int i = 0; i < inputSize+1; i++){ 
			if(pInput.val(i,0) == 1)
				uPInput.val(i,0) = 1; //i.e. gets input from all motors. 
			if(i > sensornumber + 1)	
				uPInput.val(i,0) = 1; //For now, the actor influences all motors. 
	}


	   actorWeights.set(motornumber,sensornumber); // initialized 0
	   actorWeights=actorWeights.map(random_minusone_to_one)*0.01;

	   offspringActorWeights.set(motornumber,sensornumber); 
	   offspringActorWeights = actorWeights; 

	//Each loop has a fitness
	fitness = 0;
	prediction_error = 0;
	prediction_error_time_average = 0;
	old_prediction_error_time_average = 0;

	addInspectableMatrix("PredInLoop",&prediction,false);
	//addInspectableMatrix("PredError",&parent_error,false);
	//addInspectableMatrix("UPredError",&offspring_error,false);
	parent_error.set(trial_length,1); 
	
	offspring_error.set(trial_length,1); 
	

};