Package org.apache.commons.collections.primitives

Examples of org.apache.commons.collections.primitives.DoubleList


      }
   }

   private int findClaster(Sample sample, int clastersCount)
   {
      DoubleList clasters = new ArrayDoubleList();

      int inputsCount = sample.getInput().size();
      for (int i = 0; i < clastersCount; ++i)
      {
         clasters.add(sample.getInput().get(sample.getInput().size() - clastersCount + i));
      }

      return JNMFMathUtils.indexOfMaxElement(clasters);
   }
View Full Code Here


   public DoubleList transform(DoubleList vector, VariableType type)
   {
      Validate.isTrue(inClassValue != outClassValue, "inClassValue == outClassValue");
      Validate.isTrue(vector.size() > 0, "Vector calcCountOfItems is 0");

      DoubleList result = new ArrayDoubleList();

      int closestValueIndex = -1;
      double minDisnance = Double.MAX_VALUE;
      for (int i = 0; i < vector.size(); ++i)
      {
         double distance = Math.abs(vector.get(i) - inClassValue);
         if (distance < minDisnance)
         {
            closestValueIndex = i;
            minDisnance = distance;
         }
      }

      double res = closestValueIndex + 1;

      if (classToValueTable != null)
      {
         res = classToValueTable.get(res);
      }

      result.add(res);

      return result;
   }
View Full Code Here

   }


   public boolean hasNextStep()
   {
      DoubleList currentResult = getResult();
      for (int i = 0; i < currentResult.size(); ++i)
      {
         System.out.print(currentResult.get(i) + ", ");
      }
      System.out.println();

      drawResult(currentResult);
      if (isEquals(lastResult, currentResult))
View Full Code Here

   public DoubleList getResult()
   {
      Layer last = builder.getNetwork().getLayers().getLast();

      DoubleList result = new ArrayDoubleList();
      for (Neuron neuron : last.getNeurons())
      {
         result.add(neuron.getActivation());
      }

      return result;
   }
View Full Code Here

    * @return the results of execution of neural network
    */
   public DoubleList getResult()
   {
      Layer lastLayer = layers.getLast();
      DoubleList result = new ArrayDoubleList();

      for (Neuron n : lastLayer.getNeurons())
      {
         result.add(n.getActivation());
      }

      return result;
   }
View Full Code Here

   {
      for (int i = 0; i < originalLearningData.size(); ++i)
      {
         Sample pair = originalLearningData.get(i);

         DoubleList input = pair.getInput();

         Color c1 = Color.WHITE;
         Color c2 = Color.BLACK;
         if (originalLearningData.getOutputsCount() > 1)
         {
            Color color = null;
            int winner = JNMFMathUtils.indexOfMaxElement(pair.getOutput());
            if (winner == 0)
            {
               color = c1;
            }
            else if (winner == 1)
            {
               color = c2;
            }

            drawPoint(input.get(0), input.get(1), color);
         }
         else if (originalLearningData.getOutputsCount() == 1)
         {
            double value = pair.getOutput().get(0);

            Color color = null;
            if (value > 0)
            {
               color = c1;
            }
            else if (value <= 0)
            {
               color = c2;
            }

            drawPoint(input.get(0), input.get(1), color);
         }
      }

   }
View Full Code Here

      int[] result = new int[getOutputNeurons().size()];

      int pCount = outputNeuronsInfo.values().iterator().next().size();
      for (int i = 0; i < pCount; ++i)
      {
         DoubleList activations = new ArrayDoubleList();
         DoubleList targetValues = new ArrayDoubleList();

         for (Neuron outputNeuron : getOutputNeurons())
         {
            NeuronStepInfo step = outputNeuronsInfo.get(outputNeuron).get(i);
            activations.add(step.activation);
            targetValues.add(step.targetValue);
         }

         int indexOfMax = JNMFMathUtils.indexOfMaxElement(activations);
         if (indexOfMax == JNMFMathUtils.indexOfMaxElement(targetValues))
         {
View Full Code Here

   public DoubleList findBestCandidatesOutputWeights(Neuron candidate)
   {
      int outputsCount = getOutputNeurons().size();

      DoubleList bestWeights = null;
      double minNextE = Double.MAX_VALUE;

      for (int i = 0; i < 100; ++i)
      {
         DoubleList weights = new ArrayDoubleList(outputsCount);
         for (int j = 0; j < outputsCount; ++j)
         {
            double w = JNMFMathUtils.reflectToInterval(rand.nextDouble(), 0, 1, -1, 1);

            weights.add(w);
         }

         double nextE = calcNextE(candidate, weights);

         if (nextE < minNextE)
View Full Code Here

      for (Neuron candidateNeuron : candidates)
      {
         List<NeuronStepInfo> candidateInfo = candidateNeuronsInfo.get(candidateNeuron);

         DoubleList sigmas = new ArrayDoubleList();

         for (int p = 0; p < pCount; ++p)
         {
            double sigmaP = 0;
            for (int j = 0; j < outputNeuronsCount; ++j)
            {
               List<NeuronStepInfo> outputInfo = outputNeuronsInfo.get(getOutputNeurons().get(j));

               double avE = calcAvE(outputInfo);

               NeuronStepInfo stepPInfo = outputInfo.get(p);
               IFunction deriviative = candidateNeuron.getActivationFunction().getDerivative();
               sigmaP += Math.signum(calcCj(j, candidateNeuron)) * (stepPInfo.e - avE) *
                       deriviative.calc(candidateInfo.get(p).net);
            }

            sigmas.add(sigmaP);
         }

         sigmaPValues.put(candidateNeuron, sigmas);
      }
   }
View Full Code Here

      signalAfterTranslationEvent();
   }

   public DoubleList getOutput()
   {
      DoubleList output = new ArrayDoubleList();
      for (Neuron neuron : getNeurons())
      {
         output.add(neuron.getActivation());
      }

      return output;
   }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.primitives.DoubleList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.