コード例 #1
0
  @Test
  public void returnsConnections() {
    Set<Layer> layers = new HashSet<Layer>();
    Layer topLayer = new Layer();
    Layer middleLayer = new Layer();
    Layer bottomLayer = new Layer();

    Connections firstConnection = new FullyConnected(topLayer, middleLayer, 0, 0);
    Connections secondConnection = new FullyConnected(middleLayer, bottomLayer, 0, 0);

    topLayer.addConnection(firstConnection);
    middleLayer.addConnection(firstConnection);

    middleLayer.addConnection(secondConnection);
    bottomLayer.addConnection(secondConnection);

    layers.add(topLayer);
    layers.add(middleLayer);
    layers.add(bottomLayer);
    network.setLayers(layers);

    List<Connections> connections = network.getConnections();
    assertTrue(connections.contains(firstConnection));
    assertTrue(connections.contains(secondConnection));
  }
コード例 #2
0
  @Test
  public void returnsInputLayer() {
    Set<Layer> layers = new HashSet<Layer>();
    Layer topLayer = new Layer();
    Layer middleLayer = new Layer();
    Layer bottomLayer = new Layer();

    Connections firstConnection = new FullyConnected(topLayer, middleLayer, 0, 0);
    Connections secondConnection = new FullyConnected(middleLayer, bottomLayer, 0, 0);

    topLayer.addConnection(firstConnection);
    middleLayer.addConnection(firstConnection);

    middleLayer.addConnection(secondConnection);
    bottomLayer.addConnection(secondConnection);

    layers.add(topLayer);
    layers.add(middleLayer);
    layers.add(bottomLayer);
    network.setLayers(layers);

    assertEquals(topLayer, network.getInputLayer());
  }
コード例 #3
0
  @Test
  public void removesTopLayer() {
    Set<Layer> layers = new HashSet<Layer>();
    Layer topLayer = new Layer();
    Layer middleLayer = new Layer();
    Layer bottomLayer = new Layer();

    Connections firstConnection = new FullyConnected(topLayer, middleLayer, 0, 0);
    Connections secondConnection = new FullyConnected(middleLayer, bottomLayer, 0, 0);

    topLayer.addConnection(firstConnection);
    middleLayer.addConnection(firstConnection);

    middleLayer.addConnection(secondConnection);
    bottomLayer.addConnection(secondConnection);

    layers.add(topLayer);
    layers.add(middleLayer);
    layers.add(bottomLayer);
    network.setLayers(layers);

    assertTrue(network.removeLayer(topLayer));
  }
コード例 #4
0
  @Test
  public void returnsConnectionBetweenTwoLayers() {
    Set<Layer> layers = new HashSet<Layer>();
    Layer topLayer = new Layer();
    Layer middleLayer = new Layer();

    Connections firstConnection = new FullyConnected(topLayer, middleLayer, 0, 0);

    topLayer.addConnection(firstConnection);

    layers.add(topLayer);
    layers.add(middleLayer);
    network.setLayers(layers);

    assertEquals(firstConnection, network.getConnection(topLayer, middleLayer));
    assertEquals(firstConnection, network.getConnection(middleLayer, topLayer));
  }
コード例 #5
0
  @Test
  public void returnsNullWhenThereIsntAConnectingLayer() {
    Set<Layer> layers = new HashSet<Layer>();
    Layer topLayer = new Layer();
    Layer middleLayer = new Layer();
    Layer bottomLayer = new Layer();

    Connections firstConnection = new FullyConnected(topLayer, middleLayer, 0, 0);

    topLayer.addConnection(firstConnection);

    layers.add(topLayer);
    layers.add(middleLayer);
    network.setLayers(layers);

    assertNull(network.getConnection(topLayer, bottomLayer));
    assertNull(network.getConnection(bottomLayer, topLayer));
  }