[JayRnn]
- reduced VOCAB - changed test text
This commit is contained in:
@@ -24,23 +24,21 @@ from rbm.train import train
|
||||
from rbm.status import Status
|
||||
|
||||
# ── Hyper-parameters ──────────────────────────────────────────────────────────
|
||||
TEXT = "123456789_Call_me_Ishmael._Some_years_ago" # the character sequence to learn (matches diagram example)
|
||||
TEXT = "CHAPTER 1 LOOMINGS CALL ME ISHMAEL SOME YEARS AGO NEVER MIND HOW LONG PRECISELY HAVING LITTLE OR NO" # the character sequence to learn (matches diagram example)
|
||||
WIN = 2 # sliding-window width (= N in the diagram)
|
||||
STRIDE = 1 # sliding-window step size
|
||||
UNITS = 5
|
||||
H_SIZE = 128 # hidden units per RBM cell
|
||||
NUM_EPOCHS = 1000
|
||||
NUM_ITERATIONS = 1
|
||||
|
||||
TRAIN_PARAMS = TrainingParams(
|
||||
learning_rate = 0.1,
|
||||
learning_rate = 0.25,
|
||||
momentum = 0.5,
|
||||
num_epochs = NUM_EPOCHS,
|
||||
do_rao_blackwell = False,
|
||||
num_gibbs_samples= 1
|
||||
do_rao_blackwell = True,
|
||||
num_gibbs_samples= 1,
|
||||
do_gibbs_sample_hidden=True
|
||||
)
|
||||
#WIN=3
|
||||
#STRIDE=1
|
||||
#UNIT=3
|
||||
#WIN | |
|
||||
#U0: "JAY IS COOL"
|
||||
@@ -168,14 +166,19 @@ if __name__ == "__main__":
|
||||
model.save()
|
||||
|
||||
# test the model
|
||||
seed_str = '1234'
|
||||
seed_str = 'CHAP'
|
||||
state = SPACE*UNITS
|
||||
|
||||
result = seed_str
|
||||
ch = SPACE
|
||||
# Prime
|
||||
for s in seed_str:
|
||||
state, ch = model.forward_step(s, state)
|
||||
print(f'Predict: {ch}')
|
||||
print(f'Prime: {ch}')
|
||||
|
||||
state, ch = model.forward_step('_', state)
|
||||
for i in range(len(TEXT)):
|
||||
state, ch = model.forward_step(ch, state)
|
||||
print(f'Predict: {ch}')
|
||||
result += ch
|
||||
|
||||
print(result)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from rbm.matrix import Mat, np
|
||||
|
||||
SPACE='_'
|
||||
VOCAB = SPACE + '-.!?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
||||
SPACE=' '
|
||||
VOCAB = SPACE + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
||||
_CH2IDX = {ch: i for i, ch in enumerate(VOCAB)}
|
||||
|
||||
def clamp(vec: Mat, axis=0):
|
||||
|
||||
Reference in New Issue
Block a user