SnowBall::SnowBall(float start_height) :startHeight(start_height),dirCam(0) { Initialize(); Pos = D3DXVECTOR3(RAND_05()*20.0f,RAND_0_1()*startHeight,RAND_05()*20.0f); }
void GRBM<VIS_DIM, HID_DIM>::computeVisibleProb() { // before we actually compute anything here we need to ensure // that the hiddenProbs are binary for (int i = 0; i < HID_DIM; ++i) { hiddenProb(i) = hiddenProb(i) > RAND_0_1() ? 1. : 0.; } // we have several cases here for which the visible probabilities need to be computed: // 1) visible gaussian with learned stdev // 2) visible gaussian with added gaussian noise and fixed stdev // 3) visible gaussian withoud gaussian noise and fixed stdev // 4) visible binary if (!isVisibleBinary && isVisStdevLearned) { visibleProb = weights * hiddenProb; if (addGaussianNoise) { // add some gaussian noise to the visible units here g_float gn1, gn2; int i = 0; for (; i + 1 < visibleProb.size(); i += 2) { sampleTwoGaussian(gn1, gn2); visibleProb(i) += gn1; visibleProb(i+1) += gn2; } for (; i < visibleProb.size(); ++i) { sampleTwoGaussian(gn1, gn2); visibleProb(i) += gn1; } } visibleProb.array() = visibleProb.array() * visStdevs.array(); } else { if (!isVisibleBinary && addGaussianNoise) { sampleGaussianMat<VisVType>( visibleProb); // scale sampled matrix //visibleProb *= (1. / visStdev); // << done in next row visibleProb.array() += (visibleProb.array() / visStdev) + (weights * hiddenProb).array() / visStdev; } else { visibleProb = weights * hiddenProb; if (!isVisibleBinary) visibleProb *= (1. / visStdev); } } // add bias / prior visibleProb += visiblebias; //std::cout << "vProb: " << std::endl << visibleProb.transpose() << std::endl << std::endl; // if visible should be binary threshold via logistic activation if (isVisibleBinary) { for (int i = 0; i < visibleProb.size(); ++i) visibleProb(i) = 1. / (1 + exp(-visibleProb(i))); } }