Examples of Neuron


Examples of com.greentea.relaxation.jnmf.model.Neuron


   @Override
   public void afterLayerActivation(Layer layer)
   {
      Neuron winner = null;
      double maxActivation = Double.MIN_VALUE;

      for (Neuron neuron : layer.getNeurons())
      {
         if (maxActivation < neuron.getActivation())
View Full Code Here

Examples of com.greentea.relaxation.jnmf.model.Neuron

         {
            Layer sourceLayer = network.getLayers().get(sourceLayerIndex);

            for (int i = 0; i < sourceLayer.getNeurons().size(); ++i)
            {
               Neuron sourceNeuron = sourceLayer.getNeurons().get(i);
               String layerString = (i == 0) ? "" + sourceLayerIndex : emptyString;
               String neuronString = "" + sourceNeuronkIndex;

               Color layerColor = (sourceLayerIndex % 2 == 0) ? CellColor.EvenClass.getColor() :
                       CellColor.OddClass.getColor();
               Color neuronColor = CellColor.DefaultCell.getColor();
               row1Colors.add(layerColor);
               row2Colors.add(neuronColor);

               layersRow1.add(layerString);
               neuronsRow2.add(neuronString);

               Vector<Object> contentRow = new Vector<Object>();
               contentRow.add(layerString);
               contentRow.add(neuronString);

               List<Color> rowColors = new ArrayList<Color>();
               rowColors.add(layerColor);
               rowColors.add(neuronColor);

               for (
                       int destLayerIndex = 0;
                       destLayerIndex < network.getLayers().size(); ++destLayerIndex)
               {
                  Layer destLayer = network.getLayers().get(destLayerIndex);
                  for (Neuron destNeuron : destLayer.getNeurons())
                  {
                     double w = 0.0;

                     Color connectionColor = CellColor.DefaultCell.getColor();
                     Collection<Synapse> synapses = CollectionUtils
                             .intersection(sourceNeuron.getOutputSynapses(),
                                     destNeuron.getInputSynapses());
                     if (synapses.size() > 0)
                     {
                        w = synapses.iterator().next().getWeight();
View Full Code Here

Examples of com.neuralnetwork.shared.neurons.Neuron

   * Test method for {@link com.neuralnetwork
   * .shared.neurons.Neuron#hashCode()}.
   */
  @Test
  public final void testHashCode() {
    Neuron n = new HiddenNeuron();
    assertEquals(n.hashCode(), n.hashCode());
 
    n.setValue(null);
    n.setType(null);
    n.addOutputLink(new HiddenNeuron());
    assertEquals(n.hashCode(), n.hashCode());
    Neuron v = new OutputNeuron();
    v.setValue(null);
    v.setType(null);
    v.setActivationFunction(null);
    assertEquals(v.hashCode(), v.hashCode());
  }
View Full Code Here

Examples of com.neuralnetwork.shared.neurons.Neuron

   * com.neuralnetwork.shared.neurons.NeuronType)}.
   */
  @Test
  public final void testNeuronNeuronType() {

    Neuron n = new InputNeuron();
    Neuron m = new OutputNeuron();
    Neuron o = new HiddenNeuron();
   
    assertEquals(n.getType(), NeuronType.INPUT);
    assertEquals(m.getType(), NeuronType.OUTPUT);
    assertEquals(o.getType(), NeuronType.HIDDEN);
  }
View Full Code Here

Examples of com.neuralnetwork.shared.neurons.Neuron

   * Test method for {@link com.neuralnetwork
   * .shared.neurons.Neuron#Neuron()}.
   */
  @Test
  public final void testNeuron() {
    Neuron n = new InputNeuron();
    Neuron m = new InputNeuron(new ZeroValue());
    assertEquals(n, m);
  }
View Full Code Here

Examples of com.neuralnetwork.shared.neurons.Neuron

   * com.neuralnetwork.shared.neurons.INeuron,
   * com.neuralnetwork.shared.values.IValue)}.
   */
  @Test
  public final void testAddInputLinkINeuronIValueOfQ() {
    Neuron n = new InputNeuron();
    Neuron m = new InputNeuron();
    n.addInputLink(m, new DoubleValue(TEST_VALUE1));
    ILink l = n.getInputLink(0);
    assertEquals(l.getWeight(), new DoubleValue(TEST_VALUE1));
    assertEquals(l.getHead(), n);
    assertEquals(l.getTail(), m);
View Full Code Here

Examples of eas.simulation.brain.neural.Neuron

        double leftBorder = -2;
        double rightBorder = (this.network.getNeuronCount() - 1) * this.distanceBetweenNeurons.x + 2;
       
        for (int i = 0; i < this.network.getNeuronCount(); i++) {
            Polygon2D polTarget = this.getAgentShapeInEnvironment(i);
            Neuron currentNeuron = this.network.getNeuron(i);
            double dicke = polTarget.getBoundingBox().getWidth() / 30;
            double inputOutputArrowLength = dicke * 6;
           
            // Draw input / output.
            if (currentNeuron.isInput()) {
                Color color = Color.orange;

                Polygon2D points = new Polygon2D();
                ArrayList<Double> thicks = new ArrayList<Double>(2);

                thicks.add(dicke);
                thicks.add(dicke);
                Vector2D startPoint = new Vector2D(leftBorder, polTarget.getBoundingBox().middle().y);
                points.add(startPoint);
                points.add(new Vector2D(leftBorder + inputOutputArrowLength, polTarget.getBoundingBox().middle().y));

                Polygon2D arrow = pfeilMaster.segmentPfeilPol2D(points,
                        thicks, ArrowMaster.KUGEL_ENDE,
                        ArrowMaster.EINFACHE_SPITZE_1, new Vector2D(1, 1),
                        new Vector2D(1, 1));
               
                arrow = this.getPolygonInVisualization(arrow);
               
                g.setColor(color);
                g.fillPolygon(arrow.toPol());
                g.setColor(Color.black);
                g.drawPolygon(arrow.toPol());
                g.drawString(StaticMethods.round(currentNeuron.getInput(), 2)
                        + "", (float) startPoint.x, (float) startPoint.y - 5);

                Vector2D textPos = new Vector2D(startPoint.x, startPoint.y - 0.2);
                textPos = this.getPointInVisualization(textPos);
                g.setColor(Color.blue);
                g.setFont(new Font("", Font.PLAIN, 10));
                g.drawString(
                        "[" + Math.round(currentNeuron.getInput() * 10000.0) / 10000.0 + "]",
                        (int) textPos.x,
                        (int) textPos.y);
            }

            if (currentNeuron.isOutput()) {
                Color color = Color.orange;
                Polygon2D points = new Polygon2D();
                ArrayList<Double> thicks = new ArrayList<Double>(2);
                thicks.add(dicke);
                thicks.add(dicke);
               
                Vector2D startPoint = new Vector2D(rightBorder - inputOutputArrowLength, polTarget.getBoundingBox().middle().y);
                points.add(startPoint);
                points.add(new Vector2D(rightBorder, polTarget.getBoundingBox().middle().y));

                Polygon2D arrow = pfeilMaster.segmentPfeilPol2D(points,
                        thicks, ArrowMaster.KUGEL_ENDE,
                        ArrowMaster.EINFACHE_SPITZE_1, new Vector2D(1, 1),
                        new Vector2D(1, 1));
               
                arrow = this.getPolygonInVisualization(arrow);

                g.setColor(color);
                g.fillPolygon(arrow.toPol());
                g.setColor(Color.black);
                g.drawPolygon(arrow.toPol());
                g.drawString(StaticMethods.round(currentNeuron.getOutput(), 2)
                        + "", (float) startPoint.x, (float) startPoint.y - 8);

                color = Color.orange;
               
                Vector2D textPos = new Vector2D(startPoint.x, startPoint.y - 0.2);
                textPos = this.getPointInVisualization(textPos);
                g.setColor(Color.blue);
                g.setFont(new Font("", Font.PLAIN, 10));
                g.drawString(
                        "[" + Math.round(currentNeuron.getOutput() * 10000.0) / 10000.0 + "]",
                        (int) textPos.x,
                        (int) textPos.y);
            }
           
            double maxWeight = Double.NEGATIVE_INFINITY;
            double minWeight = Double.POSITIVE_INFINITY;
            for (NeuralLink link : currentNeuron.getIncomingLinks()) {
                if (link.getWeight() > maxWeight) {
                    maxWeight = link.getWeight();
                }
                if (link.getWeight() < minWeight) {
                    minWeight = link.getWeight();
                }
            }

            // Paint links.
            for (NeuralLink link : this.network.getNeuron(i).getIncomingLinks()) {
                Polygon2D polSource = this.getAgentShapeInEnvironment(link.getSourceNeuronID());

                double xSource = polSource.getBoundingBox().middle().x;
                double ySource = 0;
                double xTarget = 0;
                double yTarget = polTarget.getBoundingBox().middle().y;
                Vector2D weightPosSelf = null;

                if (i > link.getSourceNeuronID()) {
                    ySource = polSource.getBoundingBox().lowerRightCorner().y;
                    xTarget = polTarget.getBoundingBox().upperLeftCorner().x - pfeilSpitze.getBoundingBox().getWidth();
                } else if (i < link.getSourceNeuronID()) {
                    ySource = polSource.getBoundingBox().upperLeftCorner().y;
                    xTarget = polTarget.getBoundingBox().lowerRightCorner().x + pfeilSpitze.getBoundingBox().getWidth();
                } else { // ==
                    weightPosSelf = new Vector2D(polSource.centerPoint().x - 1, polSource.centerPoint().y - 1.075);
                }
               
                Polygon2D punkte = new Polygon2D();
                punkte.add(new Vector2D(xSource, ySource));
                punkte.add(new Vector2D(xSource, yTarget));
                punkte.add(new Vector2D(xTarget, yTarget));
                LinkedList<Double> dicken = new LinkedList<Double>();
               
                double weightFactor;

                if (Math.abs(maxWeight) > Math.abs(minWeight)) {
                    minWeight = -maxWeight;
                } else {
                    maxWeight = -minWeight;
                }

                if (link.getWeight() >= 0) {
                    weightFactor = link.getWeight() / maxWeight;
                } else {
                    weightFactor = link.getWeight() / minWeight;
                }
                if (weightFactor > 0 && weightFactor < 0.26) {
                    weightFactor = 0.26;
                }
                if (weightFactor <= 0 && weightFactor > -0.26) {
                    weightFactor = -0.26;
                }

                if (Double.isNaN(weightFactor)) {
                    weightFactor = 0.1;
                }

                double actualDicke = dicke * weightFactor;
                dicken.add(actualDicke);
                dicken.add(actualDicke);
                dicken.add(actualDicke);

                // Arrow.
                Polygon2D pol = pfeilMaster.segmentPfeilPol2D(
                        punkte,
                        dicken,
                        ArrowMaster.EINFACHER_ABSCHLUSS,
                        ArrowMaster.EINFACHE_SPITZE_1,
                        new Vector2D(1, 1),
                        new Vector2D(dicke / actualDicke, dicke / actualDicke));
               
                pol = this.getPolygonInVisualization(pol);
               
                if (link.getWeight() > 0) {
                    g.setColor(Color.black);
                } else {
                    g.setColor(Color.red);
                }
               
                if (weightPosSelf == null) {
                    g.fillPolygon(pol.toPol());
                    g.drawPolygon(pol.toPol());
                }
               
                // Weight text.
                Font font;
                if (Math.abs(weightFactor) > 0.5) {
                    font = new Font("", Font.BOLD, 12);
                } else {
                    font = new Font("", Font.PLAIN, 10);
                }
               
                Vector2D weightPos = new Vector2D(
                        polSource.getBoundingBox().middle().x + 0.15,
                        polTarget.getBoundingBox().middle().y - 0.15);
               
                if (weightPosSelf != null) {
                    weightPos = weightPosSelf;
                }
               
                weightPos = this.getPointInVisualization(weightPos);
               
                g.setFont(font);
                g.drawString("" + StaticMethods.round(link.getWeight(), 2),
                        (int) weightPos.x, (int) weightPos.y);
            }
           
            Vector2D textPos = new Vector2D(i * this.distanceBetweenNeurons.x - 1, i * this.distanceBetweenNeurons.y + 1.25);
            textPos = this.getPointInVisualization(textPos);
            g.setColor(Color.blue);
            g.setFont(new Font("", Font.PLAIN, 10));
            g.drawString(
                    "[" + Math.round(currentNeuron.getNetOutput() * 10000.0) / 10000.0 + "]",
                    (int) textPos.x,
                    (int) textPos.y);
        }

        return img;
View Full Code Here

Examples of javasim.Neuron

    System.out.println("coordinates should be: na:" + inputs[0] + " cat:"
        + inputs[1] + " cas:" + inputs[2] + " a:" + inputs[3] + " kca:"
        + inputs[4] + " kd:" + inputs[5] + " h:" + inputs[6] + " leak:"
        + inputs[7]);

    Neuron neuron = new Neuron(0.0, 0.0, 0.0005, 0, 0, inputs, null, null,
        null);
    neuron = javasim.Simulator.simulate(neuron);
    CompressedNeuron c = CompressNeuron.compressNeuron(neuron);
    f.setNeuron(neuron);
    f.setCompressedNeuron(c);
View Full Code Here

Examples of org.apache.commons.math3.ml.neuralnet.Neuron

                default:
                    throw new MathInternalError(); // Cannot happen.
                }

                final Neuron aNeuron = network.getNeuron(identifiers[i][j]);
                for (long b : linkEnd) {
                    final Neuron bNeuron = network.getNeuron(b);
                    // Link to all neighbours.
                    // The reverse links will be added as the loop proceeds.
                    network.addLink(aNeuron, bNeuron);
                }
            }
View Full Code Here

Examples of org.apache.commons.math3.ml.neuralnet.Neuron

        final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bis);
        final NeuronSquareMesh2D in = (NeuronSquareMesh2D) ois.readObject();

        for (Neuron nOut : out.getNetwork()) {
            final Neuron nIn = in.getNetwork().getNeuron(nOut.getIdentifier());

            // Same values.
            final double[] outF = nOut.getFeatures();
            final double[] inF = nIn.getFeatures();
            Assert.assertEquals(outF.length, inF.length);
            for (int i = 0; i < outF.length; i++) {
                Assert.assertEquals(outF[i], inF[i], 0d);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.