// Connection Creation --- private GraphicConnection CreateGCon(NeuralConnection c, GraphicNode ingn, GraphicNode outgn) { if (c == null || ingn == null || outgn == null) { return(null); } GraphicConnection gc = new GraphicConnection(c, ingn, outgn); gCons.Add(gc); return(gc); }
private bool IsInClosedCons(NeuralConnection c, List <NeuralConnection> list) { for (int i = 0; i < list.Count; ++i) { if (list[i] == c) { return(true); } } return(false); }
public void Ctor_InitializesClass() { // Setup test values var mockTarget = new Mock<INeuralNode>(); var mockSource = new Mock<INeuralNode>(); const double ExpectedWeight = 0.11d; // Execute var actual = new NeuralConnection(ExpectedWeight, mockSource.Object, mockTarget.Object); // Verify mockSource.Verify(mock => mock.AddOutboundConnection(actual), Times.Once()); mockTarget.Verify(mock => mock.AddInboundConnection(actual), Times.Once()); Assert.AreEqual(ExpectedWeight, actual.Weight); Assert.AreSame(mockSource.Object, actual.SourceNode); Assert.AreSame(mockTarget.Object, actual.TargetNode); }
public RecogAkshaysPictureNetwork() { Globals.LearningRateForNeurons = (decimal)0.00000000000000000043368086899420177360298112034798; NeuralLayer rawInputLayer = new NeuralLayer(); for (int i = 0; i < 1024 * 1024; i++) { RawInputLayerNeuron riln = new RawInputLayerNeuron((decimal)0, (decimal)2097152); rawInputLayer.AddNeuronToLayer(riln); } Layers.Add(rawInputLayer); NeuralLayer hiddenLayer = new NeuralLayer(); for (int i = 0; i < 1024 * 1024; i++) { HiddenLayerNeuron hln = new HiddenLayerNeuron((decimal)2199023255552); hiddenLayer.AddNeuronToLayer(hln); } Layers.Add(hiddenLayer); foreach (HiddenLayerNeuron hln in hiddenLayer.LayerNeurons) { foreach (RawInputLayerNeuron riln in rawInputLayer.LayerNeurons) { NeuralConnection nc = new NeuralConnection(riln, hln, (decimal)2097152); hln.Inputs.Add(nc); riln.Outputs.Add(nc); } } NeuralLayer outputLayer = new NeuralLayer(); RawOutputLayerNeuron roln = new RawOutputLayerNeuron((decimal)2305843009213693952); foreach (HiddenLayerNeuron hln in hiddenLayer.LayerNeurons) { NeuralConnection nc = new NeuralConnection(hln, roln, (decimal)2199023255552); hln.Outputs.Add(nc); roln.Inputs.Add(nc); } }
public GraphicConnection(NeuralConnection c, GraphicNode inp, GraphicNode outp) { connection = c; inNode = inp; outNode = outp; }
public void Fire_CachesInput() { // Setup test values var mockTarget = new Mock<INeuralNode>(); var mockSource = new Mock<INeuralNode>(); const double Weight = 0.1d; const double Expected = 0.123d; // Setup target var connection = new NeuralConnection(Weight, mockSource.Object, mockTarget.Object); // Execute connection.Fire(Expected); // Verify Assert.AreEqual(Expected, connection.CachedInput); }
public void Fire_WontFireWhenAlreadyFired() { // Setup test values var mockTarget = new Mock<INeuralNode>(); var mockSource = new Mock<INeuralNode>(); const double Weight = 0.123d; const double Input = 2.34d; // Setup target var connection = new NeuralConnection(Weight, mockSource.Object, mockTarget.Object); // Execute connection.Fire(Input); connection.Fire(Input); }
public void Fire_ModifiesInputSignal() { // Setup test values var mockTarget = new Mock<INeuralNode>(); var mockSource = new Mock<INeuralNode>(); const double Weight = 0.123d; const double Input = 2.34d; const double Expected = Weight * Input; // Setup target var connection = new NeuralConnection(Weight, mockSource.Object, mockTarget.Object); // Execute connection.Fire(Input); // Verify mockTarget.Verify(mock => mock.Fire(Expected)); }
public void Fire_MaintainsFiredFlag() { // Setup test values var mockTarget = new Mock<INeuralNode>(); var mockSource = new Mock<INeuralNode>(); const double Weight = 0.123d; const double Input = 2.34d; // Setup target var connection = new NeuralConnection(Weight, mockSource.Object, mockTarget.Object); // Execute var preFiredFlag = connection.IsFired; connection.Fire(Input); var postFiredFlag = connection.IsFired; connection.ClearFire(); var postClearedFlag = connection.IsFired; // Verify Assert.IsFalse(preFiredFlag); Assert.IsTrue(postFiredFlag); Assert.IsFalse(postClearedFlag); }