Esempio n. 1
0
//------------------------------createNet()------------------------------
//
//	this method builds the ANN. The weights are all initially set to 
//	random values -1 < w < 1
//------------------------------------------------------------------------
void CNeuralNet::CreateNet()
{
	//create the layers of the network
	if (m_NumHiddenLayers > 0)
	{
		//create first hidden layer
		m_vecLayers.push_back(SNeuronLayer(m_NeuronsPerHiddenLyr, m_NumInputs));
		
		for (int i=0; i<m_NumHiddenLayers-1; ++i)
		{

			m_vecLayers.push_back(SNeuronLayer(m_NeuronsPerHiddenLyr,
				m_NeuronsPerHiddenLyr));
		}

    //create output layer
		m_vecLayers.push_back(SNeuronLayer(m_NumOutputs, m_NeuronsPerHiddenLyr));
	}

	else
	{
	  //create output layer
		m_vecLayers.push_back(SNeuronLayer(m_NumOutputs, m_NumInputs));
	}
}
Esempio n. 2
0
CNeuralNet::CNeuralNet(int numInputs, int numOutputs, int numHiddenLayers, int neuronsPerHiddenLayer):
      m_numInputs(numInputs), 
      m_numOutputs(numOutputs),
      m_numHiddenLayers(numHiddenLayers),
      m_neuronsPerHiddenLayer(neuronsPerHiddenLayer)
{
   for(int i = 0; i < numHiddenLayers; ++i)
   {
      m_vecLayers.push_back(SNeuronLayer(neuronsPerHiddenLayer,
            i > 0 ? neuronsPerHiddenLayer : numInputs));
   }
}
//------------------------------createNet()------------------------------
//
//	this method builds the ANN. The weights are all initially set to 
//	random values -1 < w < 1
//------------------------------------------------------------------------
void CNeuralNet::CreateNet()
{
	numOperacion = 0;
	//create the layers of the network
	if (m_NumHiddenLayers > 0)
	{
		//create first hidden layer
		m_vecLayers.push_back(SNeuronLayer(m_NeuronsPerHiddenLyr, m_NumInputs));

		for (int i=0; i<m_NumHiddenLayers-1; ++i)
		{

			m_vecLayers.push_back(SNeuronLayer(m_NeuronsPerHiddenLyr,
				m_NeuronsPerHiddenLyr));

		}

		//create output layer
		m_vecLayers.push_back(SNeuronLayer(m_NumOutputs, m_NeuronsPerHiddenLyr));
		for(int ik = 0; ik<4; ik++){
			for (int i=0; i<m_NumHiddenLayers + 1; ++i)
			{
			
				vector<double> auxOut;
				//for each neuron
				for (int j=0; j<m_vecLayers[i].m_NumNeurons; ++j)
				{
					auxOut.push_back(0);
				}
				outputs[ik].push_back(auxOut);
			}
		}
	}

	else
	{
		//create output layer
		m_vecLayers.push_back(SNeuronLayer(m_NumOutputs, m_NumInputs));
	}
}