public CNeuroNetWrapper(int numInputs, int numOutputs) { _cnet = CNeuroNetWrapperFunctions.__NewNeuroNet(numInputs, numOutputs); _numInputs = numInputs; _numOutputs = numOutputs; _connections = ConnectionsCollection.GetLinkedCollection(_cnet); _nodes = NodesCollection.GetLinkedConnection(_cnet); }
public bool AddNode(int ID) { if (CNeuroNetWrapperFunctions.__FindNode(_cnet, ID) == IntPtr.Zero) { CNeuroNetWrapperFunctions.__AddNode(_cnet, ID); return(true); } return(false); }
public bool AddConnection(int from, int to, double weight) { if (CNeuroNetWrapperFunctions.__FindConnection(_cnet, from, to) == IntPtr.Zero) { CNeuroNetWrapperFunctions.__AddConnection(_cnet, from, to, weight); return(true); } return(false); }
public double[] Compute(double[] inputs) { double[] res = new double[this.OutputsCount]; double[] topass = new double[this.InputsCount]; for (int i = 0; i < topass.Length; ++i) { if (i < inputs.Length) { topass[i] = inputs[i]; } else { topass[i] = 0.0; } } IntPtr arr = Marshal.AllocHGlobal(topass.Length * sizeof(double)); Marshal.Copy(topass, 0, arr, topass.Length); try { CNeuroNetWrapperFunctions.__InitInputs(_cnet, arr); } catch (System.Exception ex) { throw new Exception("Error during initialization", ex); } finally { Marshal.FreeHGlobal(arr); } IntPtr cres = CNeuroNetWrapperFunctions.__Compute(_cnet); Marshal.Copy(cres, res, 0, res.Length); Marshal.FreeHGlobal(cres); return(res); }
public CNeuroNetWrapper(CNeuroNetWrapper copy) { _numInputs = copy._numInputs; _numOutputs = copy._numOutputs; _cnet = CNeuroNetWrapperFunctions.__NewNeuroNet(_numInputs, _numOutputs); foreach (var n in copy.Nodes) { if (n.ID > _numInputs + _numOutputs) { CNeuroNetWrapperFunctions.__AddNode(_cnet, n.ID); } } foreach (var c in copy.Connections) { CNeuroNetWrapperFunctions.__AddConnection(_cnet, c.From, c.To, c.Weight); } _connections = ConnectionsCollection.GetLinkedCollection(_cnet); _nodes = NodesCollection.GetLinkedConnection(_cnet); }
IEnumerator IEnumerable.GetEnumerator() { return(new CEP(CNeuroNetWrapperFunctions.__GetEnumerator(CNeuroNetWrapperFunctions.__GetConnections(net)), net)); }
public void Clear() { CNeuroNetWrapperFunctions.__ClearNodes(net); }
public bool MoveNext() { return(CNeuroNetWrapperFunctions.__EnumeratorGoNext(_enumPtr) != 0); }
public void Dispose() { CNeuroNetWrapperFunctions.__FreeNeuroNet(_cnet); }
public void Clear() { CNeuroNetWrapperFunctions.__ClearConnections(net); }
public void Add(Connection item) { CNeuroNetWrapperFunctions.__AddConnection(net, item.From, item.To, item.Weight); }
public bool Remove(Node item) { return(CNeuroNetWrapperFunctions.__RemoveNode(net, item.ID) != 0); }
public IEnumerator <Node> GetEnumerator() { return(new NEC(CNeuroNetWrapperFunctions.__GetEnumerator(CNeuroNetWrapperFunctions.__GetNodes(net)))); }
IEnumerator IEnumerable.GetEnumerator() { return(new NEC(CNeuroNetWrapperFunctions.__GetEnumerator(CNeuroNetWrapperFunctions.__GetNodes(net)))); }
public bool Contains(Node item) { return(CNeuroNetWrapperFunctions.__FindNode(net, item.ID) != IntPtr.Zero); }
public bool Contains(Connection item) { return(CNeuroNetWrapperFunctions.__FindConnection(net, item.From, item.To) != IntPtr.Zero); }
public IEnumerator <Connection> GetEnumerator() { return(new CEP(CNeuroNetWrapperFunctions.__GetEnumerator(CNeuroNetWrapperFunctions.__GetConnections(net)), net)); }
public void Flush() { CNeuroNetWrapperFunctions.__FlushNeuroNet(_cnet); }
public bool Remove(Connection item) { return(CNeuroNetWrapperFunctions.__RemoveConnection(net, item.From, item.To) != 0); }
public void Reset() { CNeuroNetWrapperFunctions.__ResetEnumerator(_enumPtr); }
public void Add(Node item) { CNeuroNetWrapperFunctions.__AddNode(net, item.ID); }