public Perceptron(IEnumerable <ITraversableUnitReadOnly <IUnit, IConnection, IUnitActivation <IUnit> > > inputUnits) { if (inputUnits.Any() == false) { throw new ArgumentException("Input unit layer cannot be empty."); } Network = new LayeredUnitCollection <IUnit, IConnection, IUnitActivation <IUnit> >(inputUnits).GetLayeredUnits(); }
public void LayeredUnitsSeparatesUnitsIntoLayersCorrectly() { var inputs = _network.GetInputs(); var layeredUnitCollection = new LayeredUnitCollection <IUnit, IConnection, IUnitActivation <IUnit> >(inputs).GetLayeredUnits(); layeredUnitCollection.ElementAt(0).Should().ContainInOrder(new List <object> { _network.Input1, _network.Input2, _network.InputUnorthodox, }); layeredUnitCollection.ElementAt(1).Should().ContainInOrder(new List <object> { _network.Hidden1, _network.Hidden2, }); layeredUnitCollection.ElementAt(2).Should().ContainInOrder(new List <object> { _network.Output1, _network.Output2, }); }
public PerceptronUnderTraining(IEnumerable <ITraversableUnitReadOnly <IUnitUnderTraining, IConnectionUnderTraining, IUnitActivationTraining> > inputUnits, IPerceptron <IUnit, IConnection, IUnitActivation <IUnit> > perceptron = null) { _perceptron = perceptron ?? new Perceptron(inputUnits); Network = new LayeredUnitCollection <IUnitUnderTraining, IConnectionUnderTraining, IUnitActivationTraining>(inputUnits).GetLayeredUnits(); }