- refactored Rbm
- added myStatus with realtime update of reconstruction - DeepStack: added up/down passes for multilayer Stacks
This commit is contained in:
+19
-2
@@ -16,10 +16,27 @@ class StackDeep(Stack):
|
||||
|
||||
return _batch
|
||||
|
||||
def train(self, batch: np.ndarray):
|
||||
def train(self, batch: np.ndarray, status=Status()):
|
||||
_batch = np.matrix.copy(batch)
|
||||
for index, layer in enumerate(self.layers):
|
||||
print(f"Train layer {index}")
|
||||
_batch = self.batch_from(batch, index)
|
||||
layer.train(_batch, cd_func=cd_jens, status=Status())
|
||||
layer.train(_batch, cd_func=cd_jens, status=status)
|
||||
|
||||
|
||||
def pass_up(self, visible: np.ndarray, from_layer_id: int = 0):
|
||||
h = np.matrix.copy(visible)
|
||||
for layer in self.layers[from_layer_id:]:
|
||||
h = layer.gibbs_v_to_h(h)
|
||||
return h
|
||||
|
||||
def pass_down(self, hidden: np.ndarray, from_layer_id: int = 0):
|
||||
v = np.matrix.copy(hidden)
|
||||
for layer in list(reversed(self.layers))[from_layer_id:]:
|
||||
v = layer.gibbs_h_to_v(v)
|
||||
return v
|
||||
|
||||
def pass_down_up(self, visible: np.ndarray, from_layer_id: int = 0):
|
||||
h = self.pass_up(visible, from_layer_id)
|
||||
v = self.pass_down(h)
|
||||
return v
|
||||
Reference in New Issue
Block a user