Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
人
人工智能系统实战第三期
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Charles
人工智能系统实战第三期
Commits
da5da938
Commit
da5da938
authored
Dec 24, 2023
by
前钰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
03ec54cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
summary.py
人工智能系统实战第三期/实战代码/深度学习项目实战/扩散模型作业/DDPM/summary.py
+32
-0
No files found.
人工智能系统实战第三期/实战代码/深度学习项目实战/扩散模型作业/DDPM/summary.py
0 → 100644
View file @
da5da938
#--------------------------------------------#
#--------------------------------------------#
# 该部分代码用于看网络参数
#--------------------------------------------#
import
torch
from
thop
import
clever_format
,
profile
from
nets.unet
import
UNet
if
__name__
==
'__main__'
:
input_shape
=
[
64
,
64
]
num_timesteps
=
1000
device
=
torch
.
device
(
"cuda"
if
torch
.
cuda
.
is_available
()
else
"cpu"
)
m
=
UNet
(
3
)
for
i
in
m
.
children
():
print
(
i
)
print
(
'=============================='
)
dummy_input
=
torch
.
randn
(
1
,
3
,
input_shape
[
0
],
input_shape
[
1
])
.
to
(
device
)
t
=
torch
.
randint
(
0
,
num_timesteps
,
(
1
,),
device
=
device
)
flops
,
params
=
profile
(
m
.
to
(
device
),
(
dummy_input
,
t
),
verbose
=
False
)
#--------------------------------------------------------#
# flops * 2是因为profile没有将卷积作为两个operations
# 有些论文将卷积算乘法、加法两个operations。此时乘2
# 有些论文只考虑乘法的运算次数,忽略加法。此时不乘2
# 本代码选择乘2,参考YOLOX。
#--------------------------------------------------------#
flops
=
flops
*
2
flops
,
params
=
clever_format
([
flops
,
params
],
"
%.3
f"
)
print
(
'Total GFLOPS:
%
s'
%
(
flops
))
print
(
'Total params:
%
s'
%
(
params
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment