def setUp(self): net = NeuralNet() n1 = net.add_neuron() n1.Name = "input" n2 = net.add_neuron() n2.Name = "output" net.add_link(n1, n2) self.net = net
def test_RemoveLink(self): net = NeuralNet() n1 = net.add_neuron() n2 = net.add_neuron() lnk = net.add_link(n1, n2) self.assertTrue(len(net.Neurons) == 2) self.assertTrue(len(n1.Incoming) == 0) self.assertTrue(len(n1.Outgoing) == 1) self.assertTrue(n1.Outgoing[0] == lnk) self.assertTrue(len(n2.Incoming) == 1) self.assertTrue(len(n2.Outgoing) == 0) self.assertTrue(n2.Incoming[0] == lnk) self.assertEqual(n1.is_connected_outgoing(n2), lnk) self.assertEqual(n1.is_connected_incoming(n2), None) self.assertEqual(n2.is_connected_outgoing(n1), None) self.assertEqual(n2.is_connected_incoming(n1), lnk) net.remove_link(lnk) self.assertTrue(len(net.Neurons) == 2) self.assertTrue(len(n1.Incoming) == 0) self.assertTrue(len(n1.Outgoing) == 0) self.assertTrue(len(n2.Incoming) == 0) self.assertTrue(len(n2.Outgoing) == 0) self.assertEqual(n1.is_connected_outgoing(n2), None) self.assertEqual(n1.is_connected_incoming(n2), None) self.assertEqual(n2.is_connected_outgoing(n1), None) self.assertEqual(n2.is_connected_incoming(n1), None)
def test_CanCreateTwoLinksInOppositeDirection(self): net = NeuralNet() n1 = net.add_neuron() n2 = net.add_neuron() lnk1 = net.add_link(n1, n2) lnk2 = net.add_link(n2, n1) self.assertNotEqual(lnk1, lnk2)
def test_CantCreateTwoLinksInSameDirection(self): net = NeuralNet() n1 = net.add_neuron() n2 = net.add_neuron() lnk1 = net.add_link(n1, n2) lnk2 = net.add_link(n1, n2) self.assertEqual(lnk1, lnk2)
def setUp(self): net = NeuralNet() self.in1 = net.add_neuron() self.in2 = net.add_neuron() self.mid1 = net.add_neuron() self.out1 = net.add_neuron() self.out2 = net.add_neuron() net.add_link(self.in1, self.mid1, 1.0) net.add_link(self.in2, self.mid1, 1.0) net.add_link(self.mid1, self.out1, 1.0) net.add_link(self.mid1, self.out2, 1.0) self.net = net self.in1.Name = "input-1" self.in2.Name = "input-2" self.mid1.Name = "mid-1" self.out1.Name = "output-1" self.out2.Name = "output-2"
def setUp(self): net = NeuralNet() self.in1 = net.add_neuron() self.in2 = net.add_neuron() self.mid1 = net.add_neuron() self.out1 = net.add_neuron() self.out2 = net.add_neuron() net.add_link(self.in1, self.mid1, 1.0) net.add_link(self.in2, self.mid1, -1.0) net.add_link(self.mid1, self.out1, 1.0) net.add_link(self.mid1, self.out2, 1.0) self.net = net