public NNLayer(string str, NNLayer pPrev /* =NULL */) { label = str; m_pPrevLayer = pPrev; m_sigmoid = new SigmoidFunction(); m_Weights = new NNWeightList(); m_Neurons = new NNNeuronList(); }
bool m_bFloatingPointWarning; // flag for one-time warning (per layer) about potential floating point overflow public NNLayer() { label = ""; m_pPrevLayer = null; m_sigmoid = new SigmoidFunction(); m_Weights = new NNWeightList(); m_Neurons = new NNNeuronList(); Initialize(); }
virtual public void Serialize(Archive ar) { int ii, jj; if (ar.IsStoring()) { // TODO: add storing code here // TODO: add storing code here ar.Write(label); //ar.WriteString(_T("\r\n")); // ar.ReadString will look for \r\n when loading from the archive ar.Write(m_Neurons.Count); ar.Write(m_Weights.Count); foreach (NNNeuron nit in m_Neurons) { ar.Write(nit.label); ar.Write(nit.m_Connections.Count); foreach (NNConnection cit in nit.m_Connections) { ar.Write(cit.NeuronIndex); ar.Write(cit.WeightIndex); } } foreach (NNWeight wit in m_Weights) { ar.Write(wit.label); ar.Write(wit.value); } } else { // TODO: add loading code here string str; //Read Layter's label ar.Read(out str); label = str; int iNumNeurons, iNumWeights, iNumConnections; double value; NNNeuron pNeuron; NNWeight pWeight; //Read No of Neuron, Weight ar.Read(out iNumNeurons); ar.Read(out iNumWeights); if (iNumNeurons != 0) { //clear neuron list and weight list. m_Neurons.Clear(); m_Neurons = new NNNeuronList(iNumNeurons); m_Weights.Clear(); m_Weights = new NNWeightList(iNumWeights); for (ii = 0; ii < iNumNeurons; ii++) { //ar.Read Neuron's label ar.Read(out str); //Read Neuron's Connection number ar.Read(out iNumConnections); pNeuron = new NNNeuron(str, iNumConnections); pNeuron.label = str; m_Neurons.Add(pNeuron); for (jj = 0; jj < iNumConnections; jj++) { var conn = new NNConnection(); ar.Read(out conn.NeuronIndex); ar.Read(out conn.WeightIndex); pNeuron.AddConnection(conn); } } for (jj = 0; jj < iNumWeights; jj++) { ar.Read(out str); ar.Read(out value); pWeight = new NNWeight(str, value); m_Weights.Add(pWeight); } } } }