本文整理汇总了C#中Descriptor.ColumnAt方法的典型用法代码示例。如果您正苦于以下问题:C# Descriptor.ColumnAt方法的具体用法?C# Descriptor.ColumnAt怎么用?C# Descriptor.ColumnAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Descriptor
的用法示例。
在下文中一共展示了Descriptor.ColumnAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Default
/// <summary>Defaults.</summary>
/// <param name="d">The Descriptor to process.</param>
/// <param name="x">The Vector to process.</param>
/// <param name="y">The Vector to process.</param>
/// <param name="activation">The activation.</param>
/// <returns>A Network.</returns>
public static Network Default(Descriptor d, Matrix x, Vector y, IFunction activation)
{
Network nn = new Network();
// set output to number of choices of available
// 1 if only two choices
int distinct = y.Distinct().Count();
int output = distinct > 2 ? distinct : 1;
// identity funciton for bias nodes
IFunction ident = new Ident();
// set number of hidden units to (Input + Hidden) * 2/3 as basic best guess.
int hidden = (int)System.Math.Ceiling((decimal)(x.Cols + output) * 2m / 3m);
// creating input nodes
nn.In = new Node[x.Cols + 1];
nn.In[0] = new Node { Label = "B0", Activation = ident };
for (int i = 1; i < x.Cols + 1; i++)
nn.In[i] = new Node { Label = d.ColumnAt(i - 1), Activation = ident };
// creating hidden nodes
Node[] h = new Node[hidden + 1];
h[0] = new Node { Label = "B1", Activation = ident };
for (int i = 1; i < hidden + 1; i++)
h[i] = new Node { Label = String.Format("H{0}", i), Activation = activation };
// creating output nodes
nn.Out = new Node[output];
for (int i = 0; i < output; i++)
nn.Out[i] = new Node { Label = GetLabel(i, d), Activation = activation };
// link input to hidden. Note: there are
// no inputs to the hidden bias node
for (int i = 1; i < h.Length; i++)
for (int j = 0; j < nn.In.Length; j++)
Edge.Create(nn.In[j], h[i]);
// link from hidden to output (full)
for (int i = 0; i < nn.Out.Length; i++)
for (int j = 0; j < h.Length; j++)
Edge.Create(h[j], nn.Out[i]);
return nn;
}
示例2: Create
/// <summary>Defaults.</summary>
/// <param name="d">The Descriptor to process.</param>
/// <param name="x">The Vector to process.</param>
/// <param name="y">The Vector to process.</param>
/// <param name="activationFunction">The activation.</param>
/// <param name="outputFunction">The ouput function for hidden nodes (Optional).</param>
/// <param name="epsilon">epsilon</param>
/// <returns>A Network.</returns>
public static Network Create(this Network network, Descriptor d, Matrix x, Vector y, IFunction activationFunction, IFunction outputFunction = null, double epsilon = double.NaN)
{
// set output to number of choices of available
// 1 if only two choices
int distinct = y.Distinct().Count();
int output = distinct > 2 ? distinct : 1;
// identity funciton for bias nodes
IFunction ident = new Ident();
// set number of hidden units to (Input + Hidden) * 2/3 as basic best guess.
int hidden = (int)System.Math.Ceiling((double)(x.Cols + output) * 2.0 / 3.0);
return network.Create(x.Cols, output, activationFunction, outputFunction,
fnNodeInitializer: new Func<int, int, Neuron>((l, i) =>
{
if (l == 0) return new Neuron(false) { Label = d.ColumnAt(i - 1), ActivationFunction = activationFunction, NodeId = i, LayerId = l };
else if (l == 2) return new Neuron(false) { Label = Network.GetLabel(i, d), ActivationFunction = activationFunction, NodeId = i, LayerId = l };
else return new Neuron(false) { ActivationFunction = activationFunction, NodeId = i, LayerId = l };
}), hiddenLayers: hidden);
}