Ai
1 Star 0 Fork 0

dl-study/pytorch-graphsage

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lr.py 960 Bytes
一键复制 编辑 原始数据 按行查看 历史
bjohnson 提交于 2017-10-17 11:55 +08:00 . attention + learning rate scheduling
#!/usr/bin/env python
"""
lr.py
learning rate scheduler
"""
import numpy as np
class LRSchedule(object):
@staticmethod
def set_lr(optimizer, lr):
for param_group in optimizer.param_groups:
param_group['lr'] = lr
@staticmethod
def constant(x, lr_init=0.1, epochs=1):
return lr_init
@staticmethod
def step(x, breaks=(150, 250)):
if x < breaks[0]:
return 0.1
elif x < breaks[1]:
return 0.01
else:
return 0.001
@staticmethod
def linear(x, lr_init=0.1, epochs=1):
return lr_init * float(epochs - x) / epochs
@staticmethod
def cyclical(x, lr_init=0.1, epochs=1):
""" Cyclical learning rate w/ annealing """
if x < 1:
# Start w/ small learning rate
return 0.05
else:
return lr_init * (1 - x % 1) * (epochs - np.floor(x)) / epochs
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dl-study/pytorch-graphsage.git
git@gitee.com:dl-study/pytorch-graphsage.git
dl-study
pytorch-graphsage
pytorch-graphsage
master

搜索帮助