Example #1
0
void TrainingSet::setTargetSize(int ts, double fill)
{
	int ls = getTargetSize();
	resizeVectorSet(targets, ts, fill);
//	targetSize = ts;

	//Si realmente cambio el tamaƱo del patron de salidas
	if(ls != ts){
		emit targetSizeChanged(ts);
		emit targetSizeChanged(ls, ts);
	}
}
          void IdealTarget::onInit()
          {
            InternalMessage("Display","Entering IdealTarget::onInit") ;
            
            m_target_container = static_cast< ::Ogre::OverlayContainer* >(
              ::Ogre::OverlayManager::getSingleton().createOverlayElement(
                    "Panel", Utility::getUniqueName())) ;
            getOverlay()->add2D(m_target_container) ;
            
            m_target_container->setPosition(0,0) ;
            m_target_container->setWidth(1) ;
            m_target_container->setHeight(1) ;

            m_target = 
              ::Ogre::OverlayManager::getSingleton().createOverlayElement(
                    "Panel", Utility::getUniqueName()) ;

            // clone material because we will modify it 
            ::Ogre::MaterialPtr material = ::Ogre::MaterialManager::getSingleton().getByName(getIdealTargetMaterial()); 
            material = material->clone(Utility::getUniqueName()) ;
            m_target->setMaterialName(material->getName()) ; 

            m_target->setHorizontalAlignment(::Ogre::GHA_CENTER) ;
            m_target->setVerticalAlignment(::Ogre::GVA_CENTER) ;
            
            const float size = getTargetSize() ;
            
            m_target->setLeft(-size/2) ;
            m_target->setTop(-size/2) ;
            m_target->setDimensions(size,size) ;
            
            m_target_container->_addChild(m_target) ;
            m_target_container->hide() ;
            
            getOverlay()->show() ;
            onUpdate() ;
  
            InternalMessage("Display","Leaving IdealTarget::onInit") ;
          }
Example #3
0
void TrainingSet::normalize(NormalizationType no)
{
	size_t sPatterns = getPatternCount();
	size_t sInputs = getInputSize();
	size_t sTargets = getTargetSize();
	double mean;
	double stddv;
	double nor;
	vector<vector<double> >
			li = inputs,
			lt = targets;

	for(size_t p = 0; p < sPatterns; p++){
		mean = ANNFrameworkFunctions::getMean(inputs[p]);
		stddv = ANNFrameworkFunctions::getStandardDeviation(inputs[p]);
		for(size_t i = 0; i < sInputs; i++){
			nor = (inputs[p][i] - mean)/stddv;
			switch(no){
				case ITrainingSet::BipolarAutoThreshold:
					break;
				case ITrainingSet::UnipolarAutoThreshold:
					break;
				case ITrainingSet::Nothing:
					break;
				case ITrainingSet::BipolarFixedThreshold:
					break;
				case ITrainingSet::UnipolarFixedThreshold:
					break;
				case ITrainingSet::LinearFixedRange:
					break;
				case ITrainingSet::LinearAutoRange:
					break;
				case ITrainingSet::Sigmoid:
					//NOTE: no estoy seguro de que esto sea asi
					inputs[p][i] = 1/(1 + exp(-nor));
					break;
				case ITrainingSet::Tanh:
					inputs[p][i] = (1 - exp(-nor))/(1 + exp(-nor));
					break;
				case ITrainingSet::MeanDistance:
					break;
			}

		}
		mean = ANNFrameworkFunctions::getMean(targets[p]);
		stddv = ANNFrameworkFunctions::getStandardDeviation(targets[p]);
		for(size_t t = 0; t < sTargets; t++){
			nor = (targets[p][t] - mean)/stddv;
			switch(no){
				case ITrainingSet::BipolarAutoThreshold:
					break;
				case ITrainingSet::UnipolarAutoThreshold:
					break;
				case ITrainingSet::Nothing:
					break;
				case ITrainingSet::BipolarFixedThreshold:
					break;
				case ITrainingSet::UnipolarFixedThreshold:
					break;
				case ITrainingSet::LinearFixedRange:
					break;
				case ITrainingSet::LinearAutoRange:
					break;
				case ITrainingSet::Sigmoid:
					//NOTE: no estoy seguro de que esto sea asi
					targets[p][t] = 1/(1 + exp(-nor));
					break;
				case ITrainingSet::Tanh:
					targets[p][t] = (1 - exp(-nor))/(1 + exp(-nor));
					break;
				case ITrainingSet::MeanDistance:
					break;
			}
		}
	}
	inputsNorType = no;
	targetsNorType = no;

	if(li != inputs){
		emit inputsChanged(inputs);
		emit inputsChanged(li, inputs);
	}

	if(lt != targets){
		emit targetsChanged(targets);
		emit targetsChanged(lt, targets);
	}
}