本文整理汇总了C#中Index.Pos方法的典型用法代码示例。如果您正苦于以下问题:C# Index.Pos方法的具体用法?C# Index.Pos怎么用?C# Index.Pos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index.Pos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateError
/// <summary>
/// Total error calculation
/// </summary>
/// <param name="info">NetworkInfo</param>
/// <param name="inp">ref Input - input data patterns</param>
/// <param name="dout">ref Output - output data</param>
/// <param name="topo">ref Topography - topo is network topology in the form of one vector</param>
/// <param name="ww">ref Weights weights</param>
/// <param name="act">ref Activation - type of activation function</param>
/// <param name="gain">ref Gain - strengthening the activation function</param>
/// <param name="iw">ref WeightsPointers - index pointers used for network topology stored in top in the form of one vector</param>
/// <remarks>Network error will be overriden so please save it</remarks>
public double CalculateError(ref NetworkInfo info, ref Input inp, ref Output dout, ref Topography topo,
Weights ww, ref Activation act, ref Gain gain, ref Index iw)
{
try
{
Error = 0;
for (p = 0; p < info.np; p++)
{
node.Clear();
node.AddRange(inp.Data[p]);
for (n = 0; n < info.nn; n++)
{
net = ww[iw.Pos(n)];
int from = iw.Pos(n) + 1;
int to = iw.Pos(n + 1) - 1;
for (i = from; i <= to; i++)
{
net += node[(int)topo[i]] * ww[i];
}
node.Add(ActivationFunction.computeFunction(ref n, ref net, ref act, ref gain));
}
for (k = 0; k < info.no; k++)
{
Error += System.Math.Pow((dout.Data[p][k] - node[info.nio + k]), 2);
}
}
return Error;
}
catch (System.Exception ex)
{
throw new NeuralNetworkError("Błąd uaktualnienia błędu sieci neuronowej. " + ex.Message, ex);
}
}
示例2: Compute
/// <summary>
/// Compute psudo hessian matrix and its gradient
/// </summary>
/// <param name="info">NetworkInfo - information about neural network</param>
/// <param name="inp">Input - input data patterns used for learn</param>
/// <param name="dout">Output - output data patterns used for learn</param>
/// <param name="topo">Topography - neural network topography</param>
/// <param name="ww">Weights - weights</param>
/// <param name="act">Activation - activation function selection</param>
/// <param name="gain">Gain - neuron gain</param>
/// <param name="iw">Index - topography indexes</param>
public void Compute(ref NetworkInfo info, ref Input inp, ref Output dout, ref Topography topo,
Weights ww, ref Activation act, ref Gain gain, ref Index iw)
{
GradientMat = MatrixMB.Zeros(info.nw, 1);
HessianMat = MatrixMB.Zeros(info.nw, info.nw);
np = info.np;//number of patterns
ni = info.ni;//number of inputs
no = info.no;//number of outputs
nw = info.nw;//number of weights
nn = info.nn;//number of neurons
nio = nn + ni - no;
zeros = ni.Zeros();
delo = MatrixMB.Zeros(1, nio + 1);
J = MatrixMB.Zeros(1, nw);
for (p = 0; p < np; p++)
{
node.Clear();
node.AddRange(inp.Data[p]);
CalculateFunctionValuesAndDerivates(ref ww, ref iw, ref topo, ref act, ref gain);
for (k = 0; k < no; k++)
{
o = nio + k;
error = dout.Data[p][k] - node[o];
J.ClearWithZeros();
s = iw.Pos(o - ni);
J.Data[0][s] = -derivates[o];
delo.ClearWithZeros();
CalculateJacobian(ref ww, ref iw, ref topo);
CalculateForHiddenLayer(ref iw, ref topo, ref ww);
if (dout[p, 0] > 0.5) J = J * ratio;
var JT = J.Transposed;
GradientMat = GradientMat + JT * error;
HessianMat = HessianMat + JT * J;
}
}
}