public LinearNetworkArchitecture AppendStart(LinearNetworkArchitecture other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (other.LayerCount == 0) { return(this); } if (LayerCount > 0) { LayerConstruct firstOwn = _layerConstructs.First(); LayerConstruct lastOther = other._layerConstructs.Last(); lastOther.AddOutput(firstOwn); firstOwn.AddInput(lastOther); } for (int i = other._layerConstructs.Count - 1; i >= 0; i--) { _layerConstructs.Insert(0, other._layerConstructs[i]); } UpdateRegistry(); return(this); }
public static LinearNetworkArchitecture operator *(int multiplier, LinearNetworkArchitecture self) { if (multiplier <= 0) { throw new ArgumentException($"Multiplier must be >= 1, but multiplier was {multiplier}."); } if (self.LayerCount == 0) { return(self); } if (multiplier >= 2) { if (self._layerConstructs.Any(construct => !construct.UnresolvedName.Contains('#'))) { throw new ArgumentException("Attempted to multiply linear network architecture containing layer construct with static name, which cannot be multiplied. Include '#' in layer name for dynamic auto naming."); } } LinearNetworkArchitecture multipliedSelf = new LinearNetworkArchitecture(); for (int i = 0; i < multiplier; i++) { LinearNetworkArchitecture copy = (LinearNetworkArchitecture)self.DeepCopy(); multipliedSelf.AppendEnd(copy); } return(multipliedSelf); }
public LinearNetworkArchitecture AppendEnd(LinearNetworkArchitecture other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (other.LayerCount == 0) { return(this); } if (LayerCount > 0) { LayerConstruct lastOwn = _layerConstructs.Last(); LayerConstruct firstOther = other._layerConstructs.First(); lastOwn.AddOutput(firstOther); firstOther.AddInput(lastOwn); } _layerConstructs.AddRange(other._layerConstructs); UpdateRegistry(); return(this); }
/// <summary>Determines whether the specified object is equal to the current object.</summary> /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns> /// <param name="obj">The object to compare with the current object. </param> public override bool Equals(object obj) { LinearNetworkArchitecture asLinearNetworkArchitecture = obj as LinearNetworkArchitecture; if (asLinearNetworkArchitecture == null) { return(false); } if (_layerConstructs.Count != asLinearNetworkArchitecture._layerConstructs.Count) { return(false); } for (int i = 0; i < _layerConstructs.Count; i++) { if (!_layerConstructs[i].TypeEquals(asLinearNetworkArchitecture._layerConstructs[i])) { return(false); } } return(true); }