override public Dictionary <string, Matrix> CalcGradient(Vector p_error = null) { NeuralGroup core = _groups["core"]; core.CalcDerivs(false); if (p_error == null) { core.CalcDelta(false); } else { core.Delta = Vector.HadamardProduct(core.Derivs, p_error); } foreach (Connection c in core.GetInConnections()) { if (c.Trainable) { c.CalcGradient(false); _gradients[c.Id] = c.Gradient; } } return(_gradients); }
override public Dictionary <string, Tensor> CalcGradientT(Tensor p_error = null) { NeuralGroup core = _groups["core"]; core.CalcDerivs(true); if (p_error == null) { core.CalcDelta(true); } else { core.DeltaT = core.DerivsT * p_error; } foreach (Connection c in core.GetInConnections()) { if (c.Trainable) { c.CalcGradient(true); _gradients_t[c.Id] = c.GradientT; } } return(_gradients_t); }
protected void ActivateGroup(string p_group, bool p_bias, bool p_tensor) { NeuralGroup group = _groups[p_group]; foreach (Connection c in group.GetInConnections()) { if (p_tensor) { group.Integrate(c.InGroup.OutputT, c.Weights); } else { group.Integrate(c.InGroup.Output, c.Weights); } } if (p_bias) { group.AddBias(p_tensor); } group.Activate(p_tensor); }