/// <summary> /// Copy the weights of another layer in reversed order. This /// can be used to update visible layers from hidden layers and /// vice-versa. /// </summary> /// /// <param name="layer">The layer to copy the weights from.</param> /// public void CopyReversedWeightsFrom(StochasticLayer layer) { for (int i = 0; i < Neurons.Length; i++) { for (int j = 0; j < inputsCount; j++) { this.Neurons[i].Weights[j] = layer.Neurons[j].Weights[i]; } } }
/// <summary> /// Copy the weights of another layer in reversed order. This /// can be used to update visible layers from hidden layers and /// vice-versa. /// </summary> /// /// <param name="layer">The layer to copy the weights from.</param> /// public void CopyReversedWeightsFrom(StochasticLayer layer) { for (int i = 0; i < Neurons.Length; i++) for (int j = 0; j < inputsCount; j++) this.Neurons[i].Weights[j] = layer.Neurons[j].Weights[i]; }
/// <summary> /// Creates a new <see cref="RestrictedBoltzmannMachine"/>. /// </summary> /// /// <param name="function">The activation function to use in the network neurons.</param> /// <param name="inputsCount">The number of inputs for the machine.</param> /// <param name="hiddenNeurons">The number of hidden neurons in the machine.</param> /// public RestrictedBoltzmannMachine(IStochasticFunction function, int inputsCount, int hiddenNeurons) : base(function, inputsCount, 1) { this.visible = new StochasticLayer(function, inputsCount, hiddenNeurons); this.hidden = new StochasticLayer(function, hiddenNeurons, inputsCount); base.layers[0] = hidden; }
/// <summary> /// Copy the weights of another layer in reversed order. This /// can be used to update visible layers from hidden layers and /// vice-versa. /// </summary> /// /// <param name="layer">The layer to copy the weights from.</param> /// public void CopyReversedWeightsFrom(StochasticLayer layer) { int hiddenNeurons = Neurons.Length; int visibleNeurons = inputsCount; for (int i = 0; i < hiddenNeurons; i++) for (int j = 0; j < inputsCount; j++) this.Neurons[i].Weights[j] = layer.Neurons[j].Weights[i]; }
/// <summary> /// Creates a new <see cref="RestrictedBoltzmannMachine"/>. /// </summary> /// /// <param name="hidden">The hidden layer to be added in the machine.</param> /// <param name="visible">The visible layer to be added in the machine.</param> /// public RestrictedBoltzmannMachine(StochasticLayer hidden, StochasticLayer visible) : base(null, hidden.InputsCount, 0) { this.hidden = hidden; this.visible = visible; base.layers[0] = hidden; }