@@ -63,17 +63,17 @@ NN::NN(int iNumHiddenLayers, int iNumInputs, int iNumNeuronsPerHiddenLayer, int
6363 m_Layers.emplace_back (new NNLayer (iNumOutputs, iNumNeuronsPerHiddenLayer));
6464}
6565
66- void NN::setWeights (std::vector<ga_value>* weights) const
66+ void NN::setWeights (const std::vector<ga_value>* weights) const
6767{
68- unsigned short int w = 0 ;
68+ unsigned int w = 0 ;
6969
7070 for (const NNLayer* l : m_Layers)
7171 {
72- for (unsigned short int j = 0 ; j < l->numNeurons (); j++)
72+ for (unsigned int j = 0 ; j < l->numNeurons (); j++)
7373 {
7474 CPerceptron* n = l->getNeuron (j);
7575
76- for (unsigned short int k = 0 ; k < n->numWeights (); k++)
76+ for (unsigned int k = 0 ; k < n->numWeights (); k++)
7777 {
7878 n->setWeight (k, (*weights)[w++]);
7979 }
@@ -85,25 +85,25 @@ void NN::getWeights(std::vector<ga_value>* weights) const
8585{
8686 for (const NNLayer* l : m_Layers)
8787 {
88- for (unsigned short int j = 0 ; j < l->numNeurons (); j++)
88+ for (unsigned int j = 0 ; j < l->numNeurons (); j++)
8989 {
9090 const CPerceptron* n = l->getNeuron (j);
9191
92- for (unsigned short int k = 0 ; k < n->numWeights (); k++)
92+ for (unsigned int k = 0 ; k < n->numWeights (); k++)
9393 {
9494 weights->emplace_back (n->getWeight (k));
9595 }
9696 }
9797 }
9898}
9999
100- void NN::trainOutputs (std::vector<ga_value>* wanted_outputs) const
100+ void NN::trainOutputs (const std::vector<ga_value>* wanted_outputs) const
101101{
102- unsigned short int w = 0 ;
102+ unsigned int w = 0 ;
103103
104104 for (const NNLayer* l : m_Layers)
105105 {
106- for (unsigned short int j = 0 ; j < l->numNeurons (); j++)
106+ for (unsigned int j = 0 ; j < l->numNeurons (); j++)
107107 {
108108 CPerceptron* n = l->getNeuron (j);
109109
@@ -120,7 +120,7 @@ void NN::getOutputs(std::vector<ga_value>* outputs) const
120120
121121 for (const NNLayer* l : m_Layers)
122122 {
123- for (unsigned short int j = 0 ; j < l->numNeurons (); j++)
123+ for (unsigned int j = 0 ; j < l->numNeurons (); j++)
124124 {
125125 const CPerceptron* n = l->getNeuron (j);
126126
@@ -131,7 +131,7 @@ void NN::getOutputs(std::vector<ga_value>* outputs) const
131131
132132void NN::execute (std::vector <ga_value>* outputs, std::vector <ga_value>* inputs) const
133133{
134- unsigned short int i;
134+ unsigned int i;
135135
136136 std::vector<ga_value> newoutputs;
137137
@@ -146,7 +146,7 @@ void NN::execute(std::vector <ga_value>* outputs, std::vector <ga_value>* inputs
146146
147147 newoutputs.clear ();
148148
149- for (unsigned short int j = 0 ; j < l->numNeurons (); j++)
149+ for (unsigned int j = 0 ; j < l->numNeurons (); j++)
150150 {
151151 CPerceptron* n = l->getNeuron (j);
152152
@@ -158,8 +158,8 @@ void NN::execute(std::vector <ga_value>* outputs, std::vector <ga_value>* inputs
158158
159159 outputs->clear ();
160160
161- for (unsigned int k = 0 ; k < newoutputs. size (); k++ )
162- outputs->emplace_back (newoutputs[k] );
161+ for (float & newoutput : newoutputs)
162+ outputs->emplace_back (newoutput );
163163 }
164164}
165165
@@ -243,7 +243,7 @@ void NN::randomize() const
243243{
244244 for (const NNLayer* l : m_Layers)
245245 {
246- for (unsigned short int j = 0 ; j < l->numNeurons (); j++)
246+ for (unsigned int j = 0 ; j < l->numNeurons (); j++)
247247 {
248248 l->getNeuron (j)->randomize ();
249249 }
@@ -256,7 +256,7 @@ void NN::freeMemory()
256256 {
257257 NNLayer* l = m_Layer;
258258
259- for (unsigned short int j = 0 ; j < l->numNeurons (); j++)
259+ for (unsigned int j = 0 ; j < l->numNeurons (); j++)
260260 {
261261 l->freeMemory ();
262262 }
0 commit comments