<commit_before>
import numpy as np

from learning.dataset import BarsData, FromModel, MNIST
from learning.stbp_layers import  STBPStack, SigmoidBeliefLayer, FactoizedBernoulliTop
from learning.training import Trainer
from learning.termination import LogLikelihoodIncrease, EarlyStopping
from learning.monitor import MonitorLL, DLogModelParams

n_vis = 28*28
n_hid = 100
n_qhid = 2*n_hid

dataset = MNIST(which_set='train')
valiset = MNIST(which_set='valid', n_datapoints=1000)
smallset = MNIST(which_set='valid', n_datapoints=100)

layers=[
    SigmoidBeliefLayer( 
        unroll_scan=1,
        n_lower=n_vis,
        n_qhid=n_qhid,
    ),
    FactoizedBernoulliTop(
        n_lower=n_hid,
    )
]

model = STBPStack(
    layers=layers
)

trainer = Trainer(
    n_samples=10,
    learning_rate_p=1e-3,
    learning_rate_q=1e-3,
    learning_rate_s=1e-3,
    layer_discount=0.50,
    batch_size=10,
    data=dataset, 
    model=model,
    termination=EarlyStopping(),
    epoch_monitors=[MonitorLL(data=valiset, n_samples=25), DLogModelParams()],
    step_monitors=[MonitorLL(data=smallset, n_samples=[1, 5, 25, 100])],
    monitor_nth_step=100,
)

<commit_msg>MNISTR convergence monitoring with 100 samples<commit_after>
import numpy as np

from learning.dataset import BarsData, FromModel, MNIST
from learning.stbp_layers import  STBPStack, SigmoidBeliefLayer, FactoizedBernoulliTop
from learning.training import Trainer
from learning.termination import LogLikelihoodIncrease, EarlyStopping
from learning.monitor import MonitorLL, DLogModelParams

n_vis = 28*28
n_hid = 100
n_qhid = 2*n_hid

dataset = MNIST(which_set='train')
valiset = MNIST(which_set='valid', n_datapoints=1000)
smallset = MNIST(which_set='valid', n_datapoints=100)

layers=[
    SigmoidBeliefLayer( 
        unroll_scan=1,
        n_lower=n_vis,
        n_qhid=n_qhid,
    ),
    FactoizedBernoulliTop(
        n_lower=n_hid,
    )
]

model = STBPStack(
    layers=layers
)

trainer = Trainer(
    n_samples=10,
    learning_rate_p=1e-3,
    learning_rate_q=1e-3,
    learning_rate_s=1e-3,
    layer_discount=0.50,
    batch_size=10,
    data=dataset, 
    model=model,
    termination=EarlyStopping(),
    epoch_monitors=[MonitorLL(data=valiset, n_samples=100), DLogModelParams()],
    step_monitors=[MonitorLL(data=smallset, n_samples=[1, 5, 25, 100])],
    monitor_nth_step=100,
)


{'fraction_non_alphanumeric': 0.09838846480067855, 'fraction_numerical': 0.0364715860899067, 'mean_word_length': 4.616666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3261237', 'n_tokens_mistral': 948, 'n_tokens_neox': 874, 'n_words': 155}