tune hyperparams, add README, simplify training loop
- reduce WIN to 3 and H_SIZE to 32 for faster iteration - increase NUM_EPOCHS to 1000 and collapse NUM_ITERATIONS to a single pass - add README_JayRnn.md with algorithm description and ASCII architecture diagrams Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,13 +24,13 @@ from rbm.train import train
|
||||
from rbm.status import Status
|
||||
|
||||
# ── Hyper-parameters ──────────────────────────────────────────────────────────
|
||||
TEXT = " HALLO SUPER JENS UND SUPER MAUSI!" # the character sequence to learn (matches diagram example)
|
||||
WIN = 5 # sliding-window width (= N in the diagram)
|
||||
TEXT = "HALLO SUPER JENS UND SUPER MAUSI!" # 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 = 180 # hidden units per RBM cell
|
||||
NUM_EPOCHS = 100
|
||||
NUM_ITERATIONS = 10
|
||||
H_SIZE = 32 # hidden units per RBM cell
|
||||
NUM_EPOCHS = 1000
|
||||
NUM_ITERATIONS = 1
|
||||
|
||||
TRAIN_PARAMS = TrainingParams(
|
||||
learning_rate = 0.04,
|
||||
@@ -80,7 +80,7 @@ class RnnModel(Model):
|
||||
def train(self, vc: Mat, status: Status = None):
|
||||
for unit in self.units:
|
||||
train(unit, vc, status)
|
||||
# Update context portion of vc
|
||||
# For the next unit: Update context portion of vc
|
||||
_c = unit.forward(vc)
|
||||
vc[1:, WIN*vocab_size():] = _c[0:-1,:]
|
||||
|
||||
@@ -120,9 +120,8 @@ 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)
|
||||
for k in range(NUM_ITERATIONS):
|
||||
model.train(vc_train, status=Status())
|
||||
model.save()
|
||||
model.train(vc_train, status=Status())
|
||||
model.save()
|
||||
|
||||
# test the model
|
||||
seed_str = 'HA^'
|
||||
|
||||
Reference in New Issue
Block a user