本文整理汇总了C#中Layer.Think方法的典型用法代码示例。如果您正苦于以下问题:C# Layer.Think方法的具体用法?C# Layer.Think怎么用?C# Layer.Think使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer.Think方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Think_CausesEachNeuronInLayerToThink
public void Think_CausesEachNeuronInLayerToThink()
{
Layer layer = new Layer(numberOfNeurons: 2);
// Give each neuron one input and one output.
layer.Neurons[0].Inputs.Add(new Synapse { Weight = 1, Value = 4 });
layer.Neurons[1].Inputs.Add(new Synapse { Weight = 2, Value = 3 });
layer.Neurons[0].Outputs.Add(new Synapse());
layer.Neurons[1].Outputs.Add(new Synapse());
// Reset the biases since we know they are randomized, and we want to disregard them.
layer.Neurons[0].Bias = layer.Neurons[1].Bias = 0;
// Execute the code to test.
layer.Think();
// Validate that each neuron sets the value for its output.
// -4 is the sum of the neurons bias and all its inputs weights times their value.
Assert.AreEqual(
1 / (1 + Math.Pow(Math.E, -4)),
layer.Neurons[0].Outputs[0].Value,
"First neuron output");
// -6 is the sum of the neurons bias and all its inputs weights times their value.
Assert.AreEqual(
1 / (1 + Math.Pow(Math.E, -6)),
layer.Neurons[1].Outputs[0].Value,
"Second neuron output");
}