- wrap numpy and cupy in matrix as np

- added type alias Mat for np.ndarray
This commit is contained in:
2025-12-18 18:14:03 +01:00
parent 9000e70607
commit c1c6c610ad
8 changed files with 51 additions and 47 deletions
+3 -3
View File
@@ -1,9 +1,9 @@
import numpy as np
from params import RbmParams
from state import RbmState
from status import Status
from cd_train import cd_jens
from entity import Entity
from matrix import Mat, np
class Layer:
def __init__(self, name: str, shape: tuple[int, int, int, int], params: RbmParams):
@@ -43,7 +43,7 @@ def xor():
layer.load()
# Prepare training data
training_batch = np.array([[0,1,1], [0,0,0], [1,1,0], [1,0,1]], dtype=np.float64)
training_batch = Mat([[0,1,1], [0,0,0], [1,1,0], [1,0,1]], dtype=np.float64)
# Train layer
layer.entity.train(training_batch, cd_jens, Status())
@@ -52,7 +52,7 @@ def xor():
layer.save()
# Test with test data
test_batch = np.array([[0,0,0], [0,1,0], [1,0,0], [1,1,0]], dtype=np.float64)
test_batch = Mat([[0,0,0], [0,1,0], [1,0,0], [1,1,0]], dtype=np.float64)
for pattern in test_batch:
h = layer.entity.gibbs_v_to_h(pattern)
v = layer.entity.gibbs_h_to_v(h)