- DeppeStack: simplified upPass, downPass

This commit is contained in:
2024-01-21 15:25:50 +01:00
parent 5a963d805f
commit d5a64f6e6b
+4 -8
View File
@@ -87,14 +87,12 @@ arma::mat DeepStack::upDownPass(size_t layerId, const arma::mat& v)
arma::mat DeepStack::upPass(Layer *pLayer, arma::mat const &v) arma::mat DeepStack::upPass(Layer *pLayer, arma::mat const &v)
{ {
arma::mat h = arma::zeros(0,0); arma::mat h = v;
arma::mat tv = v;
while(pLayer) while(pLayer)
{ {
if (pLayer->isEnable()) if (pLayer->isEnable())
{ {
h = pLayer->to_h_gibbs(tv); h = pLayer->to_h_gibbs(h);
tv = h;
} }
pLayer = pLayer->next; pLayer = pLayer->next;
} }
@@ -103,14 +101,12 @@ arma::mat DeepStack::upPass(Layer *pLayer, arma::mat const &v)
arma::mat DeepStack::downPass(Layer *pLayer, arma::mat const &h) arma::mat DeepStack::downPass(Layer *pLayer, arma::mat const &h)
{ {
arma::mat v = arma::zeros(0,0); arma::mat v = h;
arma::mat th = h;
while(pLayer) while(pLayer)
{ {
if (pLayer->isEnable()) if (pLayer->isEnable())
{ {
v = pLayer->to_v_gibbs(th); v = pLayer->to_v_gibbs(v);
th = v;
} }
pLayer = pLayer->prev; pLayer = pLayer->prev;
} }