Skip to content
Back to skills

Reinforce Training Loop

ASecurity

Run bounded REINFORCE stochastic-policy training loops with sampled actions, scalar rewards, baselines, and optimizer traces.

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 9, 2026
testingpythonbashgit

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill reinforce_training_loop --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Reinforce Training Loop?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Reinforce Training Loop
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-reinforce-training-loop/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-reinforce-training-loop)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
name: reinforce_training_loop
description: Run bounded REINFORCE stochastic-policy training loops with sampled actions, scalar rewards, baselines, and optimizer traces.
---

# REINFORCE Training Loop

Use this skill to recover or test Williams-style REINFORCE behavior on a small stochastic environment. It is appropriate when the evidence must show sampled stochastic actions, scalar reinforcement, score-function updates, and changed policy parameters. Do not use it for deterministic policy-gradient, Q-learning, or supervised imitation-only experiments.

## Inputs

- Initial Bernoulli logit or equivalent stochastic policy parameters.
- Reward function mapping sampled actions to scalar rewards.
- Episode count, learning rate, random seed, and baseline value.
- Optional path to the `score_function_estimator` script for cross-checking the local score term.

## Outputs

- Episode-level trace containing action probability, sampled action, reward, advantage, update, and parameter value.
- Summary metrics before and after training.
- `params_before` and `params_after` fields suitable for Distiller recovery validation.
- Mechanism booleans for stochastic sampling and optimizer execution.

## Workflow

1. Initialize the stochastic policy and compute its expected reward before training.
2. For every episode, sample an action from the current policy distribution.
3. Observe scalar reward and compute the REINFORCE score-function update.
4. Apply `theta += learning_rate * update` and record the parameter transition.
5. Report expected reward after training and verify that parameters changed.
6. When used in recovery, save the trace under `recovery/logs/training_trace.json`.

## Validation

Run:

```bash
python scripts/train_bandit.py --episodes 128 --seed 7 --output /tmp/reinforce_trace.json
python -m pytest tests
```

The tests assert that the better action's probability and expected reward improve in a deterministic seeded two-action bandit.

## Limitations

This skill is a reduced mechanism-faithful recovery harness. It does not claim to reproduce every historical example from the paper or delayed-reinforcement variants.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…