<jupyter_start><jupyter_text>[![Github](https://img.shields.io/github/stars/lab-ml/nn?style=social)](https://github.com/lab-ml/nn)[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lab-ml/nn/blob/master/labml_nn/transformers/fast_weights/experiment.ipynb)                     Fast Weights TransformerThis is an experiment training Shakespeare dataset with a Compressive Transformer model. Install the `labml-nn` package<jupyter_code>!pip install labml-nn<jupyter_output>Collecting labml-nn
[?25l  Downloading https://files.pythonhosted.org/packages/a4/07/d33ead6f84fad2a4e8ff31ccd42864ff7b942785ad9f80d7c98df1c20a02/labml_nn-0.4.94-py3-none-any.whl (171kB)
[K     |████████████████████████████████| 174kB 16.4MB/s 
[?25hCollecting labml>=0.4.110
[?25l  Downloading https://files.pythonhosted.org/packages/eb/c8/98b18d0dda3811998838734f9a32e944397fdd6bb0597cef0ae2b57338e3/labml-0.4.110-py3-none-any.whl (106kB)
[K     |████████████████████████████████| 112kB 34.7MB/s 
[?25hCollecting labml-helpers>=0.4.76
  Downloading https://files.pythonhosted.org/packages/49/df/4d920a4a221acd3cfa384dddb909ed0691b08682c0d8aeaabeee2138624f/labml_helpers-0.4.76-py3-none-any.whl
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from labml-nn) (1.19.5)
Requirement already satisfied: torch in /usr/local/lib/python3.7/dist-packages (from labml-nn) (1.8.0+cu101)
Collecting einops
  Downloading https://files.pythonhosted.org/packages/5d/a0/9935e03[...]<jupyter_text>Imports<jupyter_code>from labml import experiment
from labml.configs import FloatDynamicHyperParam
from labml_nn.rl.ppo.experiment import Trainer<jupyter_output><empty_output><jupyter_text>Create an experiment<jupyter_code>experiment.create(name="ppo")<jupyter_output><empty_output><jupyter_text>Configurations<jupyter_code>configs = {
    # number of updates
    'updates': 10000,
    # number of epochs to train the model with sampled data
    'epochs': 4,
    # number of worker processes
    'n_workers': 8,
    # number of steps to run on each process for a single update
    'worker_steps': 128,
    # number of mini batches
    'batches': 4,
    # Value loss coefficient
    'value_loss_coef': FloatDynamicHyperParam(0.5),
    # Entropy bonus coefficient
    'entropy_bonus_coef': FloatDynamicHyperParam(0.01),
    # Clip range
    'clip_range': FloatDynamicHyperParam(0.1),
    # Learning rate
    'learning_rate': FloatDynamicHyperParam(2.5e-4, (0, 1e-3)),
}<jupyter_output><empty_output><jupyter_text>Set experiment configurations<jupyter_code>experiment.configs(configs)<jupyter_output><empty_output><jupyter_text>Create trainer<jupyter_code>trainer = Trainer(
    updates=configs['updates'],
    epochs=configs['epochs'],
    n_workers=configs['n_workers'],
    worker_steps=configs['worker_steps'],
    batches=configs['batches'],
    value_loss_coef=configs['value_loss_coef'],
    entropy_bonus_coef=configs['entropy_bonus_coef'],
    clip_range=configs['clip_range'],
    learning_rate=configs['learning_rate'],
)<jupyter_output><empty_output><jupyter_text>Start the experiment and run the training loop.<jupyter_code>with experiment.start():
    trainer.run_training_loop()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.06379731379731379, 'mean_word_length': 5.8989473684210525, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 30, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '86274', 'license': 'MIT', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1224, 'n_words': 166, 'path': 'labml_nn/rl/ppo/experiment.ipynb', 'repo_name': 'nbswords/nn', 'size': '3276'}