Package com.neuralnetwork.shared.neurons

Examples of com.neuralnetwork.shared.neurons.HiddenNeuron


   */
  @Test
  public final void testGetOutputLinks() {
    Neuron n = new InputNeuron()
    Neuron n1 = new InputNeuron();
    Neuron m = new HiddenNeuron();
    Neuron o = new OutputNeuron();
    Neuron o1 = new OutputNeuron();
    n.addOutputLink(m);
    n1.addOutputLink(m);
    m.addOutputLink(o);
    m.addOutputLink(o1);
   
    ILink[] l = m.getOutputLinks(0, 1);
   
    assertEquals(l[0].getTail(), o);
    assertEquals(l[1].getTail(), o1);
   
    l = m.getOutputLinks();
   
    assertEquals(l[0].getTail(), o);
    assertEquals(l[1].getTail(), o1);
  }
View Full Code Here


     */
  @Test
  public final void testSetOutputLinkIntILink() {
         Neuron n = new InputNeuron();  
          Neuron n1 = new InputNeuron();
          Neuron m = new HiddenNeuron();
          Neuron o = new OutputNeuron();
          Neuron o1 = new OutputNeuron();
          n.addOutputLink(m);
          n1.addOutputLink(m);
          m.addOutputLink(o);
          m.addOutputLink(o1);
         
          ILink[] l = m.getOutputLinks(0, 1);
          m.setOutputLink(0, l[1]);
            m.setOutputLink(1, l[0]);
          assertEquals(l[0].getTail(), o);
          assertEquals(l[1].getTail(), o1);
  }
View Full Code Here

     */
    @Test
    public final void testSetOutputLinkILinkArray() {
           Neuron n = new InputNeuron();  
            Neuron n1 = new InputNeuron();
            Neuron m = new HiddenNeuron();
            Neuron o = new OutputNeuron();
            Neuron o1 = new OutputNeuron();
            n.addOutputLink(m);
            n1.addOutputLink(m);
            m.addOutputLink(o);
            m.addOutputLink(o1);
           
            ILink[] l = m.getOutputLinks(0, 1);
            m.setOutputLinks(l);
            assertEquals(l[0].getTail(), o);
            assertEquals(l[1].getTail(), o1);
           
            l = m.getInputLinks(0, 1);
          m.setInputLink(0, l[1]);
            m.setInputLink(1, l[0]);
            assertEquals(l[0].getTail(), n);
            assertEquals(l[1].getTail(), n1);
    }
View Full Code Here

     */
    @Test
    public final void testSetInputLink() {
      Neuron n = new InputNeuron();  
        Neuron n1 = new InputNeuron();
        Neuron m = new HiddenNeuron();
        Neuron o = new OutputNeuron();
        Neuron o1 = new OutputNeuron();
        m.addInputLink(n);
        m.addInputLink(n1);
        m.addOutputLink(o);
        m.addOutputLink(o1);
       
        ILink[] l = m.getOutputLinks(0, 1);
        m.setInputLinks(l);
        assertEquals(l[0].getHead(), m);
        assertEquals(l[1].getHead(), m);
        assertEquals(l[0].getTail(), o);
        assertEquals(l[1].getTail(), o1);
    }
View Full Code Here

     */
    @Test
    public final void testInputs() {
      Neuron n = new InputNeuron();
        Neuron n1 = new InputNeuron();
        Neuron m = new HiddenNeuron();

        m.addInputLink(n);
        m.addInputLink(n1);
        Vector<ILink> v = new Vector<ILink>();
        v.add(m.getInputLinks(0)[0]);
        v.add(m.getInputLinks(1)[0]);
       
      m.setInputs(v);
        assertEquals(v.get(0).getHead(), m);
        assertEquals(v.get(1).getHead(), m);
        assertEquals(v.get(0).getTail(), n);
        assertEquals(v.get(1).getTail(), n1);
      m.setInputs(null);
        assertNull(m.getInputs());
        v.clear();
      m.setInputs(v);
        assertEquals(m.getInputs().size(), 0);
    }
View Full Code Here

   *
   * @return
   *     true if the reset method is not working correctly.
   */
  private boolean getResetTestResult() {
    Neuron m = new HiddenNeuron();
    Neuron o = new OutputNeuron();
    Neuron o1 = new OutputNeuron();
    m.addOutputLink(o);
    m.addOutputLink(o1);
   
    ILink[] l = m.getOutputLinks(0, 1);
    DoubleValue v = l[0].getWeight();
    DoubleValue v1 = l[1].getWeight();
   
    m.reset();
   
    ILink[] l1 = m.getOutputLinks(0, 1);
    DoubleValue v2 = l1[0].getWeight();
    DoubleValue v3 = l1[1].getWeight();
    return v.equals(v2) && v1.equals(v3);
  }
View Full Code Here

   * .shared.neurons.Neuron#setActivationFunction(
   * com.neuralnetwork.shared.functions.IActivationFunction)}.
   */
  @Test
  public final void testSetActivationFunction() {
    Neuron m = new HiddenNeuron();
    Neuron o = new OutputNeuron();
    Neuron o1 = new OutputNeuron();
    m.addOutputLink(o);
    m.addOutputLink(o1);
    m.setActivationFunction(null);
    assertEquals(m.getActivationFunction(), null);
    m.setActivationFunction(new SigmoidFunction());
    assertEquals(m.getActivationFunction(), new SigmoidFunction());
  }
View Full Code Here

   * Test method for {@link com.neuralnetwork
   * .shared.neurons.Neuron#getActivationFunction()}.
   */
  @Test
  public final void testGetActivationFunction() {
    Neuron m = new HiddenNeuron();
    Neuron o = new OutputNeuron();
    Neuron o1 = new OutputNeuron();
    m.addOutputLink(o);
    m.addOutputLink(o1);
    m.setActivationFunction(null);
    assertEquals(m.getActivationFunction(), null);
    m.setActivationFunction(new SigmoidFunction());
    assertEquals(m.getActivationFunction(), new SigmoidFunction());
  }
View Full Code Here

     */
    @Test
    public final void testFeedforward() {
        Neuron n = new InputNeuron(new DoubleValue(D_0_1));
        Neuron n1 = new InputNeuron(new DoubleValue(D_0_1));
        Neuron m = new HiddenNeuron();
        Neuron o = new OutputNeuron();
        Neuron o1 = new OutputNeuron();
        n.addOutputLink(m);
        n1.addOutputLink(m);
        m.addOutputLink(o);
        m.addOutputLink(o1);

        assertEquals(m.getInputLink(0), n.getOutputLink(0));

        LOGGER.debug("====== Before Feedforward ======");
        LOGGER.debug(n + " " + n1);
        LOGGER.debug(m.toString());
        LOGGER.debug(o + " " + o1);
        LOGGER.debug("================================");
       
        n.feedforward(new DoubleValue(D_0_1),
            new NeuralNetContext(null));
       
        LOGGER.debug("======= After Feedforward =======");
        LOGGER.debug(n + " " + n1);
        LOGGER.debug(m.toString());
        LOGGER.debug(o + " " + o1);
        LOGGER.debug("=================================");
    }
View Full Code Here

    n.setActivationFunction(new SigmoidFunction());
    assertFalse(n.equals(n1));
   
    Neuron i = new InputNeuron();
    Neuron i1 = new InputNeuron();
    Neuron m = new HiddenNeuron();
    Neuron o = new OutputNeuron();
    Neuron o1 = new OutputNeuron();
   
    i.addOutputLink(m);
    i1.addOutputLink(m);
    m.addOutputLink(o);
    m.addOutputLink(o1);
   
    i.getNextChild();
    assertFalse(i.equals(i1));
   
    o.getNextParent();
View Full Code Here

TOP

Related Classes of com.neuralnetwork.shared.neurons.HiddenNeuron

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.