- refactored
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@818 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+8
-32
@@ -197,43 +197,19 @@ bool AStack::saveWeights()
|
||||
return true;
|
||||
}
|
||||
|
||||
arma::mat AStack::upPass(size_t layerId, const arma::mat& v)
|
||||
arma::mat AStack::trainingBatchFrom(size_t layerId, const arma::mat& batch)
|
||||
{
|
||||
arma::mat h = arma::zeros(0,0);
|
||||
arma::mat tv = v;
|
||||
Layer *pLayer = getLayer(layerId);
|
||||
while(pLayer)
|
||||
arma::mat thisBatch = batch;
|
||||
Layer *pLayer = getLayer(0);
|
||||
while (pLayer)
|
||||
{
|
||||
if (pLayer->isEnable())
|
||||
if (pLayer->id() == layerId)
|
||||
{
|
||||
h = pLayer->to_h_gibbs(tv);
|
||||
tv = h;
|
||||
break;
|
||||
}
|
||||
thisBatch = pLayer->toHiddenProbs(thisBatch);
|
||||
pLayer = pLayer->next;
|
||||
}
|
||||
return h;
|
||||
return thisBatch;
|
||||
}
|
||||
|
||||
arma::mat AStack::downPass(size_t layerId, const arma::mat& h)
|
||||
{
|
||||
arma::mat v = arma::zeros(0,0);
|
||||
arma::mat th = h;
|
||||
Layer *pLayer = getLayer(layerId);
|
||||
while(pLayer)
|
||||
{
|
||||
if (pLayer->isEnable())
|
||||
{
|
||||
v = pLayer->to_v_gibbs(th);
|
||||
th = v;
|
||||
}
|
||||
pLayer = pLayer->prev;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
arma::mat AStack::upDownPass(size_t layerId, const arma::mat& v)
|
||||
{
|
||||
arma::mat h = upPass(layerId, v);
|
||||
arma::mat r = downPass(numLayers()-1, h);
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user