public void CalcHiddenStates(float[] in_visible_vector, float[] out_hidden) { // val for our prng // http://en.wikipedia.org/wiki/Linear_congruential_generator (Numerical Recipes vals) const uint a = 1664525; const uint c = 1013904223; fixed(float *v = in_visible_vector, h = out_hidden) { for (uint j = 0; j < _hidden; j++) { // activation h[j] = _hidden_biases[j]; for (uint i = 0; i < _visible; i++) { h[j] += _visible_features[j][i] * v[i]; } // probability h[j] = Sigmoid.Calc(h[j]); _random[j] = _random[j] * a + c; // state h[j] = (_random[j] < h[j] * uint.MaxValue) ? 1.0f : 0.0f; } } }
public void CalcHiddenProbabilities(float[] in_visible_vector, float[] out_hidden) { fixed(float *v = in_visible_vector, h = out_hidden) { for (uint j = 0; j < _hidden; j++) { h[j] = _hidden_biases[j]; for (uint i = 0; i < _visible; i++) { h[j] += _visible_features[j][i] * v[i]; } h[j] = Sigmoid.Calc(h[j]); } } }