-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ lib/ | |
pyvenv.cfg | ||
lop.egg-info | ||
__pycache__/ | ||
share/ | ||
*.pyc | ||
data/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,73 @@ | ||
# Loss of Plasticity in Deep Continual Learning | ||
|
||
This repository contains the implementation of three continual supervised learning problems. | ||
In our forthcoming paper _Loss Plasticity in Deep Continual Learning_, | ||
we show the loss of plasticity in deep learning in these problems. | ||
## Contents | ||
|
||
- [Overview](#overview) | ||
- [Repository Contents](#repo-contents) | ||
- [System Requirements](#system-requirements) | ||
- [Installation Guide](#installation-guide) | ||
- [License](./LICENSE) | ||
- [Citation](./citation.bib) | ||
|
||
## Overview | ||
|
||
Artificial neural networks, deep-learning methods, and the backpropagation algorithm form the foundation of modern machine learning and artificial intelligence. | ||
These methods are almost always used in two phases, one in which the network's weights are updated, and one in which the weights are held constant while the network is used or evaluated. | ||
This contrasts with natural learning and many applications, which require \textit{continual} learning. | ||
Do deep learning methods work in continual learning settings? | ||
Here we show that they do not---that standard deep-learning methods gradually lose plasticity in continual learning settings until they learn no better than a shallow network. | ||
We show such loss of plasticity using the classic ImageNet dataset and reinforcement learning problems across a wide range of variations in the network and the learning algorithm. | ||
Plasticity is maintained indefinitely only by algorithms that continually inject diversity into the network, such as our \emph{continual backpropagation} algorithm, a variation of backpropagation in which a small fraction of less-used units are continually and randomly reinitialized. | ||
Our results suggest that methods based on gradient descent are not enough---that sustained deep learning requires a random, non-gradient component to maintain variability and plasticity. | ||
|
||
|
||
A talk about this work can be found [here](https://www.youtube.com/watch?v=p_zknyfV9fY), | ||
and the [paper](https://arxiv.org/abs/2306.13812) is available on arxiv. | ||
This repository contains the code to reproduce the experiments present in the paper. | ||
|
||
## Repository Contents | ||
- [lop/algos](./lop/algos): All the algorithms used in the paper, including our new continual backpropagation algorithm. | ||
- [lop/nets](./lop/nets): The network architectures used in the paper. | ||
- [lop/imagenet](./lop/imagenet): Demonstration and mitigation of loss of plasticity in a task-incremental problem using ImageNet. | ||
- [lop/incremental_cifar](./lop/incremental_cifar): Demonstration and mitigation of loss of plasticity in a class-incremental problem. | ||
- [lop/slowly_changing_regression](./lop/slowly_changing_regression): A small problem for quick demonstration of loss of plasticity. | ||
- [lop/rl](./lop/rl): Loss of plasticity in standard reinforcement learning problems using the PPO algorithm[1]. | ||
|
||
The README files in each subdirectory contains further information on the contents of the subdirectory. | ||
|
||
## System Requirements | ||
|
||
This package only requires a standard computed with sufficient RAM (8GB+) to reproduce the experimental results. | ||
However, a GPU can significantly speed up experiments with larger networks such as the residual networks in [lop/incremental_cifar](./lop/incremental_cifar). | ||
Internet connection is required to download many of the datasets and packages. | ||
|
||
|
||
# Installation | ||
The package has been tested on Ubuntu 20.04 and python3.8. We expect this package to work on all machines that support all the packages listed in [`requirements.txt`](requirements.txt) | ||
|
||
|
||
## Installation Guide | ||
|
||
Create a virtual environment | ||
```sh | ||
mkdir ~/envs | ||
virtualenv --no-download --python=/usr/bin/python3.8 ~/envs/lop | ||
source ~/envs/lop/bin/activate | ||
pip3 install --no-index --upgrade pip | ||
``` | ||
|
||
Download the repository and install the requirements | ||
```sh | ||
git clone https://github.com/shibhansh/loss-of-plasticity.git | ||
cd loss-of-plasticity | ||
pip3 install -r requirements.txt | ||
pip3 install -e . | ||
``` | ||
|
||
Add these lines in your ~/.zshrc or ~/.bashrc | ||
Add this lines in your `~/.zshrc` or `~/.bashrc` | ||
```sh | ||
source ~/envs/lop/bin/activate | ||
``` | ||
``` | ||
|
||
Installation on a normal laptop with good internet connection should only take a few minutes | ||
|
||
[1] Schulman, J., Wolski, F., Dhariwal, P., Radford, A., & Klimov, O. (2017). Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@article{dohare2023loss, | ||
title={Loss of Plasticity in Deep Continual Learning}, | ||
author={Dohare, Shibhansh and Hernandez-Garcia, J Fernando and Rahman, Parash and Sutton, Richard S and Mahmood, A Rupam}, | ||
journal={\textit{arXiv preprint arXiv:2306.13812}}, | ||
year={2023}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Loss of plasticity in reinforcement learning | ||
|
||
This directory contains the code to demonstrate and mitigate loss of plasticity in reinforcement learning problems from the OpenAI [Gym](https://www.gymlibrary.dev/index.html). | ||
The actor and critic networks are specified in [`../net/policies.py`](../nets/policies.py) and [`../net/valuesf.py`](../nets/valuefs.py) respectively. | ||
|
||
The configurations for individual experiments can be found in [`cfg`](cfg). [`cfg/ant/std.yml`](cfg/ant/std.yml) specifies the parameters for _standard PPO_ in the _Ant-v3_ environment. | ||
The following command can be used to perform one run for this configuration file. The `-s` parameter specifies the random seed for the experiment. | ||
A single run (for 50M time-steps) on a normal laptop takes about 24 CPU-hours. | ||
|
||
```sh | ||
python3.8 run_ppo.py -c cfg/ant/std.json -s 0 | ||
``` | ||
|
||
Configuration files in [`cfg/ant/ns.yml`](cfg/ant/ns.yml), [`cfg/ant/l2.yml`](cfg/ant/l2.yml), and [`cfg/ant/cbp.yml`](cfg/ant/cbp.yml)specify the parameters for | ||
PPO with proper Adam, PPO with L2 regularization, and PPO with continual backpropagation respectively. | ||
|
||
After completing 30 runs for the four configuration files specified above, the commands below can be used to plot the left figure below. | ||
The generated figures will be in the [`plots`](plots) directory. | ||
```sh | ||
cd plots/ | ||
python3.8 fig4a.py | ||
``` | ||
|
||
![](ant.png "Various algorithms on Ant-v3") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters