Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Ranger a python package #21

Merged
merged 2 commits into from Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Expand Up @@ -32,7 +32,26 @@ Fixes:
1 - Differential Group learning rates now supported. This was fix in RAdam and ported here thanks to @sholderbach.
2 - save and then load may leave first run weights stranded in memory, slowing down future runs = fixed.


### Installation
Clone the repo, cd into it and install it in editable mode (`-e` option).
That way, these is no more need to re-install the package after modification.
```bash
git clone https://github.com/lessw2020/Ranger-Deep-Learning-Optimizer
cd Ranger-Deep-Learning-Optimizer
pip install -e .
```

### Usage
```python
from ranger import Ranger # this is from ranger.py
from ranger import RangerVA # this is from ranger913A.py
from ranger import RangerQH # this is from rangerqh.py

# Define your model
model = ...
# Each of the Ranger, RangerVA, RangerQH have different parameters.
optimizer = Ranger(model.parameters(), **kwargs)
```
Usage and notebook to test are available here:
https://github.com/lessw2020/Ranger-Mish-ImageWoof-5

Expand Down
3 changes: 3 additions & 0 deletions ranger/__init__.py
@@ -0,0 +1,3 @@
from .ranger import Ranger
from .ranger913A import RangerVA
from .rangerqh import RangerQH
File renamed without changes.
2 changes: 1 addition & 1 deletion ranger913A.py → ranger/ranger913A.py
Expand Up @@ -24,7 +24,7 @@



class Ranger(Optimizer):
class RangerVA(Optimizer):

def __init__(self, params, lr=1e-3, alpha=0.5, k=6, n_sma_threshhold=5, betas=(.95,0.999),
eps=1e-5, weight_decay=0, amsgrad=True, transformer='softplus', smooth=50,
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions setup.py
@@ -0,0 +1,11 @@
from setuptools import setup

setup(
name='ranger',
version='0.0.1',
description='Ranger - a synergistic optimizer using RAdam '
'(Rectified Adam) and LookAhead in one codebase ',
author='Less Wright',
license='Apache',
install_requires=['torch']
)