这个函数中的“ih”和“ho”是什么。这是softmax激活函数我无法理解字符串检查的原因。
public double sim(double x, string layer)
{
// Determine max
double max = double.MinValue;
if (layer == "ih")
max = (ihSum0 > ihSum1) ? ihSum0 : ihSum1;
else if (layer == "ho")
max = (hoSum0 > hoSum1) ? hoSum0 : hoSum1;
// Compute scale
double scale = 0.0;
if (layer == "ih")
scale = Math.Exp(ihSum0 - max) + Math.Exp(ihSum1 - max);
else if (layer == "ho")
scale = Math.Exp(hoSum0 - max ) + Math.Exp(hoSum1 - max);
return Math.Exp(x - max) / scale;
}