- adapted test to TrainingParameter as parat of Entity

- learn_norbs_labes start working
This commit is contained in:
2026-01-02 14:53:45 +01:00
parent 10691894d1
commit c7f820ec63
2 changed files with 32 additions and 20 deletions
+4 -5
View File
@@ -3,14 +3,13 @@ import matplotlib.pyplot as plt
from rbm.model import Model
from rbm.label import Label
from rbm.entity import Entity, EntityParams
from rbm.entity import Entity, EntityParams, TrainingParams
from rbm.matrix import Mat, np
from rbm.train import TrainingParams
class LabelLearner(Model):
def __init__(self, name: str, work_dir: str = '.'):
super().__init__(name, work_dir)
self.unit1 = Entity((16, 8), EntityParams())
self.unit1 = Entity((16, 8), EntityParams(), TrainingParams(learning_rate=0.01, momentum=0.9, do_rao_blackwell=True, num_epochs=10000))
def forward(self, x: Mat):
x = self.unit1.forward(x)
@@ -45,7 +44,7 @@ if __name__ == "__main__":
model.load()
# Train
model.train(encoded, TrainingParams(learning_rate=0.01, momentum=0.9, do_rao_blackwell=True, num_epochs=1000))
model.train(encoded)
# save state
model.save()
@@ -57,7 +56,7 @@ if __name__ == "__main__":
axes[index].imshow(img)
axes[index].axis('off')
axes[index].set_title(f'{test_labels[index]}')
print(inp)
plt.show()
print("Test: [passed]")