Skip to content

Commit 6fde475

Browse files
authored
Merge pull request #21 from mpariente/master
Make Ranger a python package
2 parents 7fbbaec + 32b8888 commit 6fde475

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,26 @@ Fixes:
3232
1 - Differential Group learning rates now supported. This was fix in RAdam and ported here thanks to @sholderbach.
3333
2 - save and then load may leave first run weights stranded in memory, slowing down future runs = fixed.
3434

35-
35+
### Installation
36+
Clone the repo, cd into it and install it in editable mode (`-e` option).
37+
That way, these is no more need to re-install the package after modification.
38+
```bash
39+
git clone https://github.com/lessw2020/Ranger-Deep-Learning-Optimizer
40+
cd Ranger-Deep-Learning-Optimizer
41+
pip install -e .
42+
```
43+
44+
### Usage
45+
```python
46+
from ranger import Ranger # this is from ranger.py
47+
from ranger import RangerVA # this is from ranger913A.py
48+
from ranger import RangerQH # this is from rangerqh.py
49+
50+
# Define your model
51+
model = ...
52+
# Each of the Ranger, RangerVA, RangerQH have different parameters.
53+
optimizer = Ranger(model.parameters(), **kwargs)
54+
```
3655
Usage and notebook to test are available here:
3756
https://github.com/lessw2020/Ranger-Mish-ImageWoof-5
3857

ranger/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .ranger import Ranger
2+
from .ranger913A import RangerVA
3+
from .rangerqh import RangerQH
File renamed without changes.

ranger913A.py renamed to ranger/ranger913A.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626

27-
class Ranger(Optimizer):
27+
class RangerVA(Optimizer):
2828

2929
def __init__(self, params, lr=1e-3, alpha=0.5, k=6, n_sma_threshhold=5, betas=(.95,0.999),
3030
eps=1e-5, weight_decay=0, amsgrad=True, transformer='softplus', smooth=50,
File renamed without changes.

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name='ranger',
5+
version='0.0.1',
6+
description='Ranger - a synergistic optimizer using RAdam '
7+
'(Rectified Adam) and LookAhead in one codebase ',
8+
author='Less Wright',
9+
license='Apache',
10+
install_requires=['torch']
11+
)

0 commit comments

Comments
 (0)