[tests] - fix CuPy display in test_learn_encoded_labels; enable model.load in test_linear

test_learn_encoded_labels: add .get() for cupy→numpy conversion before imshow;
reduce num_epochs 10000→1000.
test_linear: uncomment model.load() to resume from saved weights.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 23:45:42 +02:00
co-authored by Claude Sonnet 4.6
parent 37c6e33948
commit 17429ddce8
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -9,7 +9,7 @@ from rbm.matrix import Mat, np
class LabelLearner(Model):
def __init__(self, name: str, dim, work_dir: str = '.'):
super().__init__(name, work_dir)
self.unit1 = Entity(dim, EntityParams(do_gaussian_hidden=False), TrainingParams(learning_rate=0.01, momentum=0.9, do_rao_blackwell=True, num_epochs=10000))
self.unit1 = Entity(dim, EntityParams(do_gaussian_hidden=False), TrainingParams(learning_rate=0.01, momentum=0.9, do_rao_blackwell=True, num_epochs=1000))
def forward(self, x: Mat):
x = self.unit1.forward(x)
@@ -66,13 +66,13 @@ if __name__ == "__main__":
recon = model.backward(hidden)
img_hidden = np.reshape(hidden, (4, 4))
img_recon = np.reshape(recon, (label_w, label_h))
axes[0][index].imshow(img_hidden, cmap=cmap)
axes[0][index].imshow(img_hidden.get(), cmap=cmap)
axes[0][index].axis('off')
axes[0][index].set_title(f'{test_labels[index]}')
axes[1][index].imshow(img_recon, cmap=cmap)
axes[1][index].imshow(img_recon.get(), cmap=cmap)
axes[1][index].axis('off')
axes[1][index].set_title(f'{test_labels[index]}')
axes[2][index].imshow(np.reshape(inp, (label_w, label_h)), cmap=cmap)
axes[2][index].imshow(np.reshape(inp.get(), (label_w, label_h)), cmap=cmap)
axes[2][index].axis('off')
axes[2][index].set_title(f'{test_labels[index]}')
+1 -1
View File
@@ -40,7 +40,7 @@ def linear():
model.init(0.1)
# Load weights (if exists)
# model.load()
model.load()
# Prepare training data
training_batch = np.random.randn(N_CASES, N_VIS, dtype=np.float64)