refactored
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user