cleaned up
This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user