From 7f6818670edb55b9f2481960b74c9564d3524506 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 4 Jun 2026 16:43:41 +0200 Subject: [PATCH] - changed sample text - changed model params --- JayRnn.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/JayRnn.py b/JayRnn.py index 20723ed..9284538 100644 --- a/JayRnn.py +++ b/JayRnn.py @@ -24,17 +24,20 @@ from rbm.train import train from rbm.status import Status # ── Hyper-parameters ────────────────────────────────────────────────────────── -TEXT = " HALLO SUPER JENS. SUPER! " # the character sequence to learn (matches diagram example) +TEXT = " HALLO SUPER JENS. SUPPE! " # the character sequence to learn (matches diagram example) WIN = 3 # sliding-window width (= N in the diagram) STRIDE = 1 # sliding-window step size UNITS = 1 -H_SIZE = 120 # hidden units per RBM cell +H_SIZE = 128 # hidden units per RBM cell +NUM_EPOCHS = 100 +NUM_ITERATIONS = 100 TRAIN_PARAMS = TrainingParams( - learning_rate = 0.05, - momentum = 0.9, - num_epochs = 1000, + learning_rate = 0.25, + momentum = 0.5, + num_epochs = NUM_EPOCHS, do_rao_blackwell = True, + num_gibbs_samples= 1 ) #WIN=3 #STRIDE=1 @@ -78,7 +81,8 @@ class RnnModel(Model): for unit in self.units: train(unit, vc, status) # Update context portion of vc - vc[1:, WIN*vocab_size():] = unit.forward(vc)[0:-1,:] + _c = unit.forward(vc) + vc[1:, WIN*vocab_size():] = _c[0:-1,:] def forward_step(self, _vc: Mat): for unit in self.units: @@ -115,8 +119,9 @@ if __name__ == "__main__": # context will be updated after training c_train = np.zeros([len(batch), H_SIZE]) vc_train = concat(batch, c_train, axis=1) - model.train(vc_train, status=Status()) - model.save() + for k in range(NUM_ITERATIONS): + model.train(vc_train, status=Status()) + model.save() # test the model seed = str2vec('HA^')