Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
0e341c56
Unverified
提交
0e341c56
authored
1月 04, 2021
作者:
Glenn Jocher
提交者:
GitHub
1月 04, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create one_cycle() function (#1836)
上级
7dddb1d9
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
3 行删除
+9
-3
train.py
train.py
+3
-3
general.py
utils/general.py
+5
-0
plots.py
utils/plots.py
+1
-0
没有找到文件。
train.py
浏览文件 @
0e341c56
...
...
@@ -28,7 +28,7 @@ from utils.autoanchor import check_anchors
from
utils.datasets
import
create_dataloader
from
utils.general
import
labels_to_class_weights
,
increment_path
,
labels_to_image_weights
,
init_seeds
,
\
fitness
,
strip_optimizer
,
get_latest_run
,
check_dataset
,
check_file
,
check_git_status
,
check_img_size
,
\
print_mutation
,
set_logging
print_mutation
,
set_logging
,
one_cycle
from
utils.google_utils
import
attempt_download
from
utils.loss
import
compute_loss
from
utils.plots
import
plot_images
,
plot_labels
,
plot_results
,
plot_evolution
...
...
@@ -126,12 +126,12 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
# Scheduler https://arxiv.org/pdf/1812.01187.pdf
# https://pytorch.org/docs/stable/_modules/torch/optim/lr_scheduler.html#OneCycleLR
lf
=
lambda
x
:
((
1
+
math
.
cos
(
x
*
math
.
pi
/
epochs
))
/
2
)
*
(
1
-
hyp
[
'lrf'
])
+
hyp
[
'lrf'
]
# cosine
lf
=
one_cycle
(
1
,
hyp
[
'lrf'
],
epochs
)
# cosine 1->hyp['lrf']
scheduler
=
lr_scheduler
.
LambdaLR
(
optimizer
,
lr_lambda
=
lf
)
# plot_lr_scheduler(optimizer, scheduler, epochs)
# Logging
if
wandb
and
wandb
.
run
is
None
:
if
rank
in
[
-
1
,
0
]
and
wandb
and
wandb
.
run
is
None
:
opt
.
hyp
=
hyp
# add hyperparameters
wandb_run
=
wandb
.
init
(
config
=
opt
,
resume
=
"allow"
,
project
=
'YOLOv5'
if
opt
.
project
==
'runs/train'
else
Path
(
opt
.
project
)
.
stem
,
...
...
utils/general.py
浏览文件 @
0e341c56
...
...
@@ -102,6 +102,11 @@ def clean_str(s):
return
re
.
sub
(
pattern
=
"[|@#!¡·$€
%
&()=?¿^*;:,¨´><+]"
,
repl
=
"_"
,
string
=
s
)
def
one_cycle
(
y1
=
0.0
,
y2
=
1.0
,
steps
=
100
):
# lambda function for sinusoidal ramp from y1 to y2
return
lambda
x
:
((
1
-
math
.
cos
(
x
*
math
.
pi
/
steps
))
/
2
)
*
(
y2
-
y1
)
+
y1
def
labels_to_class_weights
(
labels
,
nc
=
80
):
# Get class weights (inverse frequency) from training labels
if
labels
[
0
]
is
None
:
# no labels loaded
...
...
utils/plots.py
浏览文件 @
0e341c56
...
...
@@ -190,6 +190,7 @@ def plot_lr_scheduler(optimizer, scheduler, epochs=300, save_dir=''):
plt
.
xlim
(
0
,
epochs
)
plt
.
ylim
(
0
)
plt
.
savefig
(
Path
(
save_dir
)
/
'LR.png'
,
dpi
=
200
)
plt
.
close
()
def
plot_test_txt
():
# from utils.plots import *; plot_test()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论