From 4bd516798a75b159c0e63e7df96ca8dd5f146e80 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 4 Jun 2026 10:36:50 +0200 Subject: [PATCH] cleaned up --- JayRnn.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/JayRnn.py b/JayRnn.py index 0e51fdc..bc119be 100644 --- a/JayRnn.py +++ b/JayRnn.py @@ -113,24 +113,17 @@ if __name__ == "__main__": vc_train = concat(batch, c_train, axis=1) # model.train(vc_train, status=Status()) model.save() + + # test the model seed = str2vec('JA^') - vc_forward = concat(seed.flatten(), c_train[0]) + v_forward = seed.flatten() + context = c_train[0] for i in range(len(TEXT)): - vc_forward = model.forward_step(vc_forward) - v_forward, c_forward = split(vc_forward.flatten(), H_SIZE) - v_forward_clamp = clamp(v_forward.reshape([WIN, vocab_size()]), axis=1) - print(f"Forward : {vec2str(v_forward_clamp, axis=1)}") - v_forward = shift_left(v_forward_clamp.reshape([1, WIN*vocab_size()]), vocab_size()) - print(f"Seed : {vec2str(v_forward.reshape([WIN, vocab_size()]), axis=1)}") - vc_forward = concat(v_forward, c_forward.reshape([1, H_SIZE]), axis=1) - - - if 0: - vc = model.forward_step(vc_forward) - vc_forward = split(vc.flatten(), c_forward) - print(vc_forward) - - win, _ = split(vc.flatten(), len(seed)) - v_str = vec2str(win.reshape(WIN, vocab_size())) - print(v_str) + print(f"Forward {i:02d}: {vec2str(v_forward.reshape([WIN, vocab_size()]), axis=1)}") + vc_forward = concat(v_forward.reshape([1, WIN*vocab_size()]), context.reshape([1, H_SIZE]), axis=1) + vc_predict = model.forward_step(vc_forward) + v_predict, context = split(vc_predict.flatten(), H_SIZE) + v_predict_clamp = clamp(v_predict.reshape([WIN, vocab_size()]), axis=1) + print(f"Predict {i:02d}: {vec2str(v_predict_clamp, axis=1)}") + v_forward = shift_left(v_predict_clamp.reshape([1, WIN*vocab_size()]), vocab_size())