Skip to content

Commit

Permalink
Behavioral cloning (#175)
Browse files Browse the repository at this point in the history
Adds a new `supervised.py` script to enn-ppo which trains a model from samples recorded by another policy. Also makes various improvements to the sample recorder:
- add `--eval-capture-samples`/`--eval-capture-logits` options to record samples/logits during eval to a file
- add `--eval-on-step-0` arg to enable/disable running eval on the first step
- add `--codecraft-only-opponent` to run an eval with only a loaded eval policy against itself (this is slightly hacky, I'm planning to remove all the CodeCraft-specific options later)
- include action and observation spaces when recording samples
- fix `RaggedBufferBool` getting deserialized to `None`
- misc fixes to the `SampleRecorder` and `Trace`

Resolves entity-neural-network/incubator#5, entity-neural-network/incubator#6, and entity-neural-network/incubator#8.
  • Loading branch information
cswinter committed Feb 22, 2022
1 parent 0a86883 commit 253592e
Show file tree
Hide file tree
Showing 5 changed files with 477 additions and 91 deletions.
46 changes: 12 additions & 34 deletions README.md
Expand Up @@ -2,40 +2,18 @@

PPO implementation compatible with Entity Gym.

Example usage:

```bash
poetry run python enn_ppo/enn_ppo/train.py
```

To run behavioral cloning on recorded samples:


## WORK IN PROGRESS Implementation details

The `rewards`, `dones`, and `values` can be stored in fixed-size preallocated tensors
as usual, since there is only one value per timestep and environment.
Observations, actions, and logprobs don't have a fixed shape and therefore require
special handling that differs during rollout and optimization.

### Rollouts

On each rollout step, environments return a `List[Observation]` and expect a `List[Dict[str, Action]]`.

Each observation has two components:

- `entities: Dict[str, np.ndarray]` maps each entity type to a (num_entity, num_feats) array of features.
- `action_masks: Mapping[str, ActionMask]` maps each action type to a list of indices of entities that can perform that action.

- `List[]

Each observation has a `Dict[str, np.ndarray]`
- shuffling
- batching

### Optimization



### Ragged batch tensors



### Issues and possible improvements


```bash
# Download data (261MB)
# Larger 5GB file with 1M samples: https://www.dropbox.com/s/o7jf4r7m0xtm80p/enhanced250m-1m-v2.blob?dl=1
wget 'https://www.dropbox.com/s/es84ml3wltxdmnh/enhanced250m-60k.blob?dl=1' -O enhanced250m-60k.blob
# Run training
poetry run python enn_ppo/enn_ppo/supervised.py --batch-size=1024 --lr=0.001 --filepath=enhanced250m-1m-60m.blob --track
```

0 comments on commit 253592e

Please sign in to comment.