public void RestoreWeights(object savedWeights) { SavedWeights save = (SavedWeights)savedWeights; hiddenLayer.IncomingWeights = save.HiddenWeights.Clone(); outputLayer.IncomingWeights = save.OutputWeights.Clone(); hiddenLayer.BiasWeights = save.HiddenBias.Clone(); outputLayer.BiasWeights = save.OutputBias.Clone(); contextLayer.Memory = save.Memory.Clone(); }
public object SaveWeights() { SavedWeights save = new SavedWeights(); save.HiddenWeights = hiddenLayer.IncomingWeights.Clone(); save.OutputWeights = outputLayer.IncomingWeights.Clone(); save.HiddenBias = hiddenLayer.BiasWeights.Clone(); save.OutputBias = outputLayer.BiasWeights.Clone(); save.Memory = contextLayer.Memory.Clone(); return(save); }
public object SaveWeights() { SavedWeights save = new SavedWeights(weightedLayers.Count); for (int i = 0; i < weightedLayers.Count; i++) { save.WeightMatrices[i] = weightedLayers[i].IncomingWeights.Clone(); if (weightedLayers[i].HasBias) { save.Biases[i] = weightedLayers[i].BiasWeights.Clone(); } } return(save); }
public void RestoreWeights(object savedWeights) { SavedWeights save = (SavedWeights)savedWeights; if (save.WeightMatrices.Length != weightedLayers.Count) { throw new ArgumentException("The number of saved matrices is different than the number of weight layers"); } for (int i = 0; i < weightedLayers.Count; i++) { weightedLayers[i].IncomingWeights = save.WeightMatrices[i].Clone(); if (weightedLayers[i].HasBias) { weightedLayers[i].BiasWeights = save.Biases[i].Clone(); } } }