public void testAnalyze() {
   BasicNetwork network = EncogUtility.simpleFeedForward(2, 2, 0, 1, false);
   double[] weights = new double[network.encodedArrayLength()];
   EngineArray.fill(weights, 1.0);
   network.decodeFromArray(weights);
   AnalyzeNetwork analyze = new AnalyzeNetwork(network);
   Assert.assertEquals(weights.length, analyze.getWeightsAndBias().getSamples());
   Assert.assertEquals(3, analyze.getBias().getSamples());
   Assert.assertEquals(6, analyze.getWeights().getSamples());
 }
Exemplo n.º 2
0
 /** Update the swarm's best position */
 protected void updateGlobalBestPosition() {
   boolean bestUpdated = false;
   for (int i = 0; i < m_populationSize; i++) {
     if ((m_bestVectorIndex == -1)
         || isScoreBetter(m_bestErrors[i], m_bestErrors[m_bestVectorIndex])) {
       m_bestVectorIndex = i;
       bestUpdated = true;
     }
   }
   if (bestUpdated) {
     m_va.copy(m_bestVector, m_bestVectors[m_bestVectorIndex]);
     m_bestNetwork.decodeFromArray(m_bestVector);
     setError(m_bestErrors[m_bestVectorIndex]);
   }
 }