Update README.md
Browse files
README.md
CHANGED
|
@@ -6,30 +6,245 @@ tags:
|
|
| 6 |
- reinforcement-learning
|
| 7 |
- ML-Agents-Pyramids
|
| 8 |
---
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
This is a trained model of a **ppo** agent playing **Pyramids**
|
| 12 |
-
using the [Unity ML-Agents Library](https://github.com/Unity-Technologies/ml-agents).
|
| 13 |
|
| 14 |
-
|
| 15 |
-
The Documentation: https://unity-technologies.github.io/ml-agents/ML-Agents-Toolkit-Documentation/
|
| 16 |
|
| 17 |
-
|
| 18 |
-
- A *short tutorial* where you teach Huggy the Dog 🐶 to fetch the stick and then play with him directly in your
|
| 19 |
-
browser: https://huggingface.co/learn/deep-rl-course/unitbonus1/introduction
|
| 20 |
-
- A *longer tutorial* to understand how works ML-Agents:
|
| 21 |
-
https://huggingface.co/learn/deep-rl-course/unit5/introduction
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
```bash
|
| 25 |
mlagents-learn <your_configuration_file_path.yaml> --run-id=<run_id> --resume
|
| 26 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
2. Step 1: Find your model_id: Adilbai/Pyramids-RL-agent-ppo
|
| 33 |
-
3. Step 2: Select your *.nn /*.onnx file
|
| 34 |
-
4. Click on Watch the agent play 👀
|
| 35 |
-
|
|
|
|
| 6 |
- reinforcement-learning
|
| 7 |
- ML-Agents-Pyramids
|
| 8 |
---
|
| 9 |
+
# PPO-Pyramids Unity ML-Agents Model
|
| 10 |
|
| 11 |
+
## Model Description
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
This model is a Proximal Policy Optimization (PPO) agent trained to navigate and solve the Pyramids environment from Unity ML-Agents. The Pyramids environment is a complex 3D navigation and puzzle-solving task where agents must learn to reach goals while avoiding obstacles and navigating through pyramid-like structures.
|
|
|
|
| 14 |
|
| 15 |
+
## Model Details
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
### Model Architecture
|
| 18 |
+
- **Algorithm**: Proximal Policy Optimization (PPO)
|
| 19 |
+
- **Framework**: Unity ML-Agents with PyTorch backend
|
| 20 |
+
- **Policy Type**: Actor-Critic with shared feature extraction
|
| 21 |
+
- **Network Architecture**:
|
| 22 |
+
- Hidden Units: 512 per layer
|
| 23 |
+
- Number of Layers: 2
|
| 24 |
+
- Activation: ReLU (default)
|
| 25 |
+
- Normalization: Disabled
|
| 26 |
+
- Visual Encoding: Simple CNN for visual observations
|
| 27 |
+
|
| 28 |
+
### Environment: Pyramids
|
| 29 |
+
|
| 30 |
+
The Pyramids environment is one of Unity ML-Agents' example environments featuring:
|
| 31 |
+
- **Objective**: Navigate to randomly spawned goal locations
|
| 32 |
+
- **Setting**: 3D pyramid-like structures with multiple levels and obstacles
|
| 33 |
+
- **Complexity**: Multi-agent environment with navigation and spatial reasoning challenges
|
| 34 |
+
- **Visual Component**: First-person or third-person visual observations
|
| 35 |
+
|
| 36 |
+
## Training Configuration
|
| 37 |
+
|
| 38 |
+
### PPO Hyperparameters
|
| 39 |
+
```yaml
|
| 40 |
+
batch_size: 128
|
| 41 |
+
buffer_size: 2048
|
| 42 |
+
learning_rate: 0.0003
|
| 43 |
+
beta: 0.01 # Entropy regularization
|
| 44 |
+
epsilon: 0.2 # PPO clipping parameter
|
| 45 |
+
lambda: 0.95 # GAE parameter
|
| 46 |
+
num_epoch: 3 # Training epochs per update
|
| 47 |
+
learning_rate_schedule: linear
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### Network Settings
|
| 51 |
+
```yaml
|
| 52 |
+
normalize: false # Input normalization
|
| 53 |
+
hidden_units: 512 # Units per hidden layer
|
| 54 |
+
num_layers: 2 # Number of hidden layers
|
| 55 |
+
vis_encode_type: simple # Visual encoder type
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### Reward Structure
|
| 59 |
+
- **Extrinsic Rewards**:
|
| 60 |
+
- Gamma: 0.99 (discount factor)
|
| 61 |
+
- Strength: 1.0
|
| 62 |
+
- Sparse rewards for reaching goals
|
| 63 |
+
- Time penalties for efficiency
|
| 64 |
+
|
| 65 |
+
- **Intrinsic Rewards (RND)**:
|
| 66 |
+
- Random Network Distillation for exploration
|
| 67 |
+
- Gamma: 0.99
|
| 68 |
+
- Strength: 0.01
|
| 69 |
+
- Separate network: 64 units, 3 layers
|
| 70 |
+
- Learning rate: 0.0001
|
| 71 |
+
|
| 72 |
+
### Training Process
|
| 73 |
+
- **Max Steps**: 1,000,000 training steps
|
| 74 |
+
- **Time Horizon**: 128 steps per trajectory
|
| 75 |
+
- **Checkpoints**: Keep 5 best models
|
| 76 |
+
- **Summary Frequency**: Every 30,000 steps
|
| 77 |
+
- **Training Time**: Approximately 4-8 hours on modern GPU
|
| 78 |
+
|
| 79 |
+
## Observation Space
|
| 80 |
+
|
| 81 |
+
The agent receives:
|
| 82 |
+
- **Visual Observations**: RGB camera input (84x84x3 typically)
|
| 83 |
+
- **Vector Observations**: Agent position, rotation, velocity
|
| 84 |
+
- **Goal Information**: Relative goal position and distance
|
| 85 |
+
- **Environmental Context**: Obstacle proximity, platform information
|
| 86 |
+
|
| 87 |
+
## Action Space
|
| 88 |
+
|
| 89 |
+
- **Action Type**: Continuous
|
| 90 |
+
- **Action Dimensions**: 3-4 continuous values
|
| 91 |
+
- Forward/backward movement
|
| 92 |
+
- Left/right movement
|
| 93 |
+
- Rotation (yaw)
|
| 94 |
+
- Optional: Jump action
|
| 95 |
+
|
| 96 |
+
## Performance Metrics
|
| 97 |
+
|
| 98 |
+
### Expected Performance
|
| 99 |
+
- **Goal Reaching Success Rate**: 80-95%
|
| 100 |
+
- **Average Episode Length**: Optimal path finding
|
| 101 |
+
- **Training Convergence**: Stable improvement over 1M steps
|
| 102 |
+
- **Exploration Efficiency**: Balanced exploration vs exploitation
|
| 103 |
+
|
| 104 |
+
### Key Metrics Tracked
|
| 105 |
+
- **Cumulative Reward**: Total reward per episode
|
| 106 |
+
- **Success Rate**: Percentage of episodes reaching goal
|
| 107 |
+
- **Episode Length**: Steps to complete episode
|
| 108 |
+
- **Policy Entropy**: Measure of action diversity
|
| 109 |
+
- **Value Function Accuracy**: Critic network performance
|
| 110 |
+
|
| 111 |
+
## Technical Implementation
|
| 112 |
+
|
| 113 |
+
### PPO Algorithm Features
|
| 114 |
+
- **Policy Clipping**: Prevents destructive policy updates (ε=0.2)
|
| 115 |
+
- **Generalized Advantage Estimation**: GAE with λ=0.95
|
| 116 |
+
- **Entropy Regularization**: Encourages exploration (β=0.01)
|
| 117 |
+
- **Value Function Learning**: Shared network with policy
|
| 118 |
+
|
| 119 |
+
### Random Network Distillation (RND)
|
| 120 |
+
- **Purpose**: Intrinsic motivation for exploration
|
| 121 |
+
- **Implementation**: Separate predictor and target networks
|
| 122 |
+
- **Benefit**: Encourages visiting novel states
|
| 123 |
+
- **Balance**: Low strength (0.01) to avoid overwhelming extrinsic rewards
|
| 124 |
+
|
| 125 |
+
### Unity ML-Agents Integration
|
| 126 |
+
- **Training Interface**: Python mlagents-learn command
|
| 127 |
+
- **Environment Communication**: Unity-Python API
|
| 128 |
+
- **Parallel Training**: Multiple environment instances
|
| 129 |
+
- **Real-time Monitoring**: TensorBoard integration
|
| 130 |
+
|
| 131 |
+
## Files and Structure
|
| 132 |
+
|
| 133 |
+
```
|
| 134 |
+
├── Pyramids.onnx # Trained policy network
|
| 135 |
+
├── Pyramids/
|
| 136 |
+
│ ├── checkpoint-{step}.onnx # Training checkpoints
|
| 137 |
+
│ ├── configuration.yaml # Training configuration
|
| 138 |
+
│ └── run_logs/ # Training metrics
|
| 139 |
+
├── results/
|
| 140 |
+
│ ├── training_summary.json # Training statistics
|
| 141 |
+
│ └── tensorboard_logs/ # TensorBoard data
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
## Usage
|
| 145 |
+
|
| 146 |
+
### Loading the Model
|
| 147 |
+
```python
|
| 148 |
+
from mlagents_envs import UnityEnvironment
|
| 149 |
+
from mlagents_envs.side_channel.engine_configuration_channel import EngineConfigurationChannel
|
| 150 |
+
|
| 151 |
+
# Load environment
|
| 152 |
+
channel = EngineConfigurationChannel()
|
| 153 |
+
env = UnityEnvironment(file_name="Pyramids", side_channels=[channel])
|
| 154 |
+
|
| 155 |
+
# Model is loaded automatically when using mlagents-learn
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
### Training Command
|
| 159 |
+
```bash
|
| 160 |
+
mlagents-learn config.yaml --env=Pyramids --run-id=pyramids_run_01
|
| 161 |
+
```
|
| 162 |
+
### Resume the training
|
| 163 |
```bash
|
| 164 |
mlagents-learn <your_configuration_file_path.yaml> --run-id=<run_id> --resume
|
| 165 |
+
```
|
| 166 |
+
### Inference
|
| 167 |
+
```python
|
| 168 |
+
# The trained model can be used directly in Unity builds
|
| 169 |
+
# or through the ML-Agents Python API for evaluation
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
## Limitations and Considerations
|
| 173 |
+
|
| 174 |
+
1. **Environment Specific**: Trained specifically for Pyramids environment layout
|
| 175 |
+
2. **Visual Dependency**: Performance tied to visual observation quality
|
| 176 |
+
3. **Exploration Balance**: RND parameters may need tuning for different scenarios
|
| 177 |
+
4. **Computational Requirements**: Requires GPU for efficient training
|
| 178 |
+
5. **Generalization**: May not transfer well to significantly different navigation tasks
|
| 179 |
+
|
| 180 |
+
## Optimization Suggestions
|
| 181 |
+
|
| 182 |
+
For improved performance, consider:
|
| 183 |
+
- **Enable normalization**: `normalize: true`
|
| 184 |
+
- **Increase network capacity**: `hidden_units: 768`
|
| 185 |
+
- **Longer time horizon**: `time_horizon: 256`
|
| 186 |
+
- **Higher batch size**: `batch_size: 256`
|
| 187 |
+
- **More training steps**: `max_steps: 2000000`
|
| 188 |
+
|
| 189 |
+
## Applications
|
| 190 |
+
|
| 191 |
+
- **Game AI**: Intelligent NPC navigation in 3D games
|
| 192 |
+
- **Robotics Research**: Transfer learning for robot navigation
|
| 193 |
+
- **Pathfinding**: Advanced pathfinding algorithm development
|
| 194 |
+
- **Educational**: Demonstration of RL in complex 3D environments
|
| 195 |
+
|
| 196 |
+
## Ethical Considerations
|
| 197 |
+
|
| 198 |
+
This model represents a benign navigation task with no ethical concerns:
|
| 199 |
+
- **Content**: Abstract geometric environment
|
| 200 |
+
- **Purpose**: Educational and research applications
|
| 201 |
+
- **Safety**: No real-world safety implications
|
| 202 |
|
| 203 |
+
## System Requirements
|
| 204 |
+
|
| 205 |
+
### Training
|
| 206 |
+
- **OS**: Windows 10+, macOS 10.14+, Ubuntu 18.04+
|
| 207 |
+
- **GPU**: NVIDIA GPU with CUDA support (recommended)
|
| 208 |
+
- **RAM**: 8GB minimum, 16GB recommended
|
| 209 |
+
- **Storage**: 2GB for environment and model files
|
| 210 |
+
|
| 211 |
+
### Dependencies
|
| 212 |
+
```
|
| 213 |
+
unity-ml-agents>=0.28.0
|
| 214 |
+
torch>=1.8.0
|
| 215 |
+
tensorboard
|
| 216 |
+
numpy
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
## Citation
|
| 220 |
+
|
| 221 |
+
If you use this model, please cite:
|
| 222 |
+
|
| 223 |
+
```bibtex
|
| 224 |
+
@misc{ppo-pyramids-2024,
|
| 225 |
+
title={PPO-Pyramids: Navigation Agent for Unity ML-Agents},
|
| 226 |
+
author={Adilbai},
|
| 227 |
+
year={2024},
|
| 228 |
+
publisher={Hugging Face Hub},
|
| 229 |
+
url={https://huggingface.co/Adilbai/ppo-pyramids}
|
| 230 |
+
}
|
| 231 |
+
```
|
| 232 |
+
|
| 233 |
+
## References
|
| 234 |
+
|
| 235 |
+
- Schulman, J., et al. (2017). Proximal Policy Optimization Algorithms. arXiv:1707.06347
|
| 236 |
+
- Burda, Y., et al. (2018). Exploration by Random Network Distillation. arXiv:1810.12894
|
| 237 |
+
- Unity Technologies. ML-Agents Toolkit Documentation
|
| 238 |
+
- Juliani, A., et al. (2018). Unity: A General Platform for Intelligent Agents. arXiv:1809.02627
|
| 239 |
+
|
| 240 |
+
## Training Logs and Monitoring
|
| 241 |
+
|
| 242 |
+
Monitor training progress through:
|
| 243 |
+
- **TensorBoard**: Real-time training metrics
|
| 244 |
+
- **Console Output**: Episode rewards and statistics
|
| 245 |
+
- **Checkpoint Analysis**: Model performance over time
|
| 246 |
+
- **Success Rate Tracking**: Goal completion percentage
|
| 247 |
+
|
| 248 |
+
---
|
| 249 |
|
| 250 |
+
*For optimal results, consider using the improved configuration with normalization enabled and increased network capacity. 🏗️🎯*
|
|
|
|
|
|
|
|
|
|
|
|