fixed armadillo read

This commit is contained in:
2025-12-17 14:04:26 +01:00
parent 4d05a59d0b
commit a1e7a803d1
2 changed files with 16 additions and 6 deletions
+15 -5
View File
@@ -1,3 +1,5 @@
import os.path
import numpy as np
from layer import Layer
from stack import Stack, StackType, StackException
@@ -35,7 +37,7 @@ def read_armadillo(filename: str) -> np.ndarray:
print(f"shape: {shape}")
result = np.zeros(shape=shape, dtype=np.float64)
line = fp.readline().replace("\n", '').split(' ')
line = fp.readline().replace("\n", '').split(' ')
line = line[1:]
data = [float(s) for s in line]
for row in range(shape[0]):
@@ -43,15 +45,23 @@ def read_armadillo(filename: str) -> np.ndarray:
return result
def main():
def main(prj_name: str = "test"):
work_dir = "../../results"
prj_root = "/home/jens/work/repos/Rbm"
prj_path = os.path.join(prj_root, f"{prj_name}.prj")
# Create stack from project file
stack = StackFactory.from_file("/home/jens/work/repos/Rbm/test.prj", work_dir="../../results")
stack = StackFactory.from_file(prj_path, work_dir=work_dir)
# Init state
stack.state_init(0.01)
# Load state
stack.state_load()
# Load train data
batch = read_armadillo("/home/jens/work/repos/Rbm/test.training.dat")
training_data_path = os.path.join(prj_root, f"{prj_name}.training.dat")
batch = read_armadillo(training_data_path)
# Train
stack.train(batch)
@@ -60,5 +70,5 @@ def main():
stack.state_save()
if __name__ == "__main__":
main()
main("norb_small_16h")
print("Test: [passed]")
+1 -1
View File
@@ -41,7 +41,7 @@ class Stack:
return layer
return None
def init(self, std: float):
def state_init(self, std: float):
for layer in self.layers:
layer.init(std)