本文整理汇总了C++中NeuralNetwork::getL方法的典型用法代码示例。如果您正苦于以下问题:C++ NeuralNetwork::getL方法的具体用法?C++ NeuralNetwork::getL怎么用?C++ NeuralNetwork::getL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork::getL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evolve
void Animal::evolve(NeuralNetwork *bestNN)
// Modify the neuronal network of the animal closer to the best one
{
NeuralNetwork* NN = evolveNN();
std::vector<NeuronLayer> layers = NN->getL();
std::vector<NeuronLayer> bestLayers = bestNN->getL();
const unsigned int layersNum=layers.size();
//for each layer
for (unsigned int layer=0; layer<layersNum; layer++)
{
std::vector<Neuron> neurons = layers.at(layer).getN();
std::vector<Neuron> bestNeurons = bestLayers.at(layer).getN();
const unsigned int neuronsNum = neurons.size();
//for each neuron
for (unsigned int neuron=0; neuron<neuronsNum; neuron++)
{
const std::vector<double> weights = neurons.at(neuron).getWeights();
const std::vector<double> bestWeights = bestNeurons.at(neuron).getWeights();
std::vector<double> newWeights;
//for each weight
for(unsigned int w=0; w<weights.size(); w++)
{ newWeights.push_back(weights.at(neuron)+(bestWeights.at(neuron)-weights.at(neuron))*0.1);
}
neurons.at(neuron).setWeights(newWeights);
}
}
}