refactored

This commit is contained in:
2025-12-19 15:20:04 +01:00
parent a293fc31a0
commit a47922cb1c
8 changed files with 92 additions and 124 deletions
+4 -4
View File
@@ -19,21 +19,21 @@ class StackDeep(Stack):
def train(self, batch: Mat, status=Status()):
_batch = np.copy(batch)
for index, layer in enumerate(self.layers):
print(f"Train layer {index} for {layer.entity.params.num_epochs} epochs")
print(f"Train layer {index} for {layer.training_params.num_epochs} epochs")
_batch = self.batch_from(batch, index)
train(layer.entity, _batch, status=status)
train(layer.entity, _batch, layer.training_params, status=status)
def pass_up(self, visible: Mat, from_layer_id: int = 0):
h = np.copy(visible)
for layer in self.layers[from_layer_id:]:
h = layer.entity.gibbs_v_to_h(h)
h = layer.entity.forward(h)
return h
def pass_down(self, hidden: Mat, from_layer_id: int = 0):
v = np.copy(hidden)
for layer in list(reversed(self.layers))[from_layer_id:]:
v = layer.entity.gibbs_h_to_v(v)
v = layer.entity.reconstruct(v)
return v
def pass_down_up(self, visible: Mat, from_layer_id: int = 0):