public static CFastCyclicNetwork Convert(FastCyclicNetwork fcn) { var cfcn = new CFastCyclicNetwork(); var numberOfNeurons = fcn._neuronActivationFnArray.Length; // Copy connections cfcn.Connections = new List<CConnection>(fcn._connectionArray.Length); foreach (var c in fcn._connectionArray) { var cc = new CConnection { ToNeuronId = c._tgtNeuronIdx, FromNeuronId = c._srcNeuronIdx, Weight = c._weight }; cfcn.Connections.Add(cc); } // Copy activation functions cfcn.ActivationFunctions = new List<string>(numberOfNeurons); foreach (var s in fcn._neuronActivationFnArray) { if (s == null) cfcn.ActivationFunctions.Add(""); else cfcn.ActivationFunctions.Add(s.FunctionId); } // Copy auxiliary arguments cfcn.NeuronAuxArgs = new List<List<double>>(numberOfNeurons); foreach (var aux in fcn._neuronAuxArgsArray) { if (aux == null) cfcn.NeuronAuxArgs.Add(new List<double>()); else cfcn.NeuronAuxArgs.Add(new List<double>(aux)); } cfcn.NeuronCount = fcn._neuronCount; cfcn.InputNeuronCount = fcn._inputNeuronCount; cfcn.OutputNeuronCount = fcn._outputNeuronCount; cfcn.TimestepsPerActivation = fcn._timestepsPerActivation; return cfcn; }
public void Read (TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 10: if (field.Type == TType.List) { { Connections = new List<CConnection>(); TList _list0 = iprot.ReadListBegin(); for( int _i1 = 0; _i1 < _list0.Count; ++_i1) { CConnection _elem2 = new CConnection(); _elem2 = new CConnection(); _elem2.Read(iprot); Connections.Add(_elem2); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 20: if (field.Type == TType.List) { { ActivationFunctions = new List<string>(); TList _list3 = iprot.ReadListBegin(); for( int _i4 = 0; _i4 < _list3.Count; ++_i4) { string _elem5 = null; _elem5 = iprot.ReadString(); ActivationFunctions.Add(_elem5); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 30: if (field.Type == TType.List) { { NeuronAuxArgs = new List<List<double>>(); TList _list6 = iprot.ReadListBegin(); for( int _i7 = 0; _i7 < _list6.Count; ++_i7) { List<double> _elem8 = new List<double>(); { _elem8 = new List<double>(); TList _list9 = iprot.ReadListBegin(); for( int _i10 = 0; _i10 < _list9.Count; ++_i10) { double _elem11 = (double)0; _elem11 = iprot.ReadDouble(); _elem8.Add(_elem11); } iprot.ReadListEnd(); } NeuronAuxArgs.Add(_elem8); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 40: if (field.Type == TType.I32) { NeuronCount = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 50: if (field.Type == TType.I32) { InputNeuronCount = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 60: if (field.Type == TType.I32) { OutputNeuronCount = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 70: if (field.Type == TType.I32) { TimestepsPerActivation = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
public void Read(TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 10: if (field.Type == TType.List) { { Connections = new List <CConnection>(); TList _list0 = iprot.ReadListBegin(); for (int _i1 = 0; _i1 < _list0.Count; ++_i1) { CConnection _elem2 = new CConnection(); _elem2 = new CConnection(); _elem2.Read(iprot); Connections.Add(_elem2); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 20: if (field.Type == TType.List) { { ActivationFunctions = new List <string>(); TList _list3 = iprot.ReadListBegin(); for (int _i4 = 0; _i4 < _list3.Count; ++_i4) { string _elem5 = null; _elem5 = iprot.ReadString(); ActivationFunctions.Add(_elem5); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 30: if (field.Type == TType.List) { { NeuronAuxArgs = new List <List <double> >(); TList _list6 = iprot.ReadListBegin(); for (int _i7 = 0; _i7 < _list6.Count; ++_i7) { List <double> _elem8 = new List <double>(); { _elem8 = new List <double>(); TList _list9 = iprot.ReadListBegin(); for (int _i10 = 0; _i10 < _list9.Count; ++_i10) { double _elem11 = (double)0; _elem11 = iprot.ReadDouble(); _elem8.Add(_elem11); } iprot.ReadListEnd(); } NeuronAuxArgs.Add(_elem8); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 40: if (field.Type == TType.I32) { NeuronCount = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 50: if (field.Type == TType.I32) { InputNeuronCount = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 60: if (field.Type == TType.I32) { OutputNeuronCount = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 70: if (field.Type == TType.I32) { TimestepsPerActivation = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }