Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
84bfa892
Unverified
提交
84bfa892
authored
9月 18, 2021
作者:
Glenn Jocher
提交者:
GitHub
9月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consolidate `init_seeds()` (#4849)
上级
302a1b0b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
5 行增加
和
13 行删除
+5
-13
general.py
utils/general.py
+5
-3
torch_utils.py
utils/torch_utils.py
+0
-10
没有找到文件。
utils/general.py
浏览文件 @
84bfa892
...
...
@@ -29,7 +29,6 @@ import yaml
from
utils.downloads
import
gsutil_getsize
from
utils.metrics
import
box_iou
,
fitness
from
utils.torch_utils
import
init_torch_seeds
# Settings
torch
.
set_printoptions
(
linewidth
=
320
,
precision
=
5
,
profile
=
'long'
)
...
...
@@ -91,10 +90,13 @@ def set_logging(rank=-1, verbose=True):
def
init_seeds
(
seed
=
0
):
# Initialize random number generator (RNG) seeds
# Initialize random number generator (RNG) seeds https://pytorch.org/docs/stable/notes/randomness.html
# cudnn seed 0 settings are slower and more reproducible, else faster and less reproducible
import
torch.backends.cudnn
as
cudnn
random
.
seed
(
seed
)
np
.
random
.
seed
(
seed
)
init_torch_seeds
(
seed
)
torch
.
manual_seed
(
seed
)
cudnn
.
benchmark
,
cudnn
.
deterministic
=
(
False
,
True
)
if
seed
==
0
else
(
True
,
False
)
def
get_latest_run
(
search_dir
=
'.'
):
...
...
utils/torch_utils.py
浏览文件 @
84bfa892
...
...
@@ -15,7 +15,6 @@ from copy import deepcopy
from
pathlib
import
Path
import
torch
import
torch.backends.cudnn
as
cudnn
import
torch.distributed
as
dist
import
torch.nn
as
nn
import
torch.nn.functional
as
F
...
...
@@ -41,15 +40,6 @@ def torch_distributed_zero_first(local_rank: int):
dist
.
barrier
(
device_ids
=
[
0
])
def
init_torch_seeds
(
seed
=
0
):
# Speed-reproducibility tradeoff https://pytorch.org/docs/stable/notes/randomness.html
torch
.
manual_seed
(
seed
)
if
seed
==
0
:
# slower, more reproducible
cudnn
.
benchmark
,
cudnn
.
deterministic
=
False
,
True
else
:
# faster, less reproducible
cudnn
.
benchmark
,
cudnn
.
deterministic
=
True
,
False
def
date_modified
(
path
=
__file__
):
# return human-readable file modification date, i.e. '2021-3-26'
t
=
datetime
.
datetime
.
fromtimestamp
(
Path
(
path
)
.
stat
()
.
st_mtime
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论