Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
Lightweight super-resolution using knowledge distillation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
영제 임
Lightweight super-resolution using knowledge distillation
Commits
e7d9d6b3
Commit
e7d9d6b3
authored
2 years ago
by
영제 임
Browse files
Options
Downloads
Patches
Plain Diff
teacher model change
parent
58b8660a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/loss/at.py
+2
-2
2 additions, 2 deletions
src/loss/at.py
src/main.py
+0
-1
0 additions, 1 deletion
src/main.py
src/trainer.py
+1
-3
1 addition, 3 deletions
src/trainer.py
src/utility.py
+2
-2
2 additions, 2 deletions
src/utility.py
with
5 additions
and
8 deletions
src/loss/at.py
+
2
−
2
View file @
e7d9d6b3
...
@@ -27,7 +27,7 @@ class AT(nn.Module):
...
@@ -27,7 +27,7 @@ class AT(nn.Module):
def
attention_map
(
self
,
fm
,
eps
=
1e-6
):
def
attention_map
(
self
,
fm
,
eps
=
1e-6
):
am
=
torch
.
pow
(
torch
.
abs
(
fm
),
self
.
p
)
am
=
torch
.
pow
(
torch
.
abs
(
fm
),
self
.
p
)
am
=
torch
.
sum
(
am
,
dim
=
1
,
keepdim
=
True
)
am
=
torch
.
sum
(
am
,
dim
=
1
,
keepdim
=
True
)
#
norm = torch.norm(am, keepdim=True)#, dim=(2,3)
norm
=
torch
.
norm
(
am
,
keepdim
=
True
)
#, dim=(2,3)
#
am = torch.div(am, norm+eps)
am
=
torch
.
div
(
am
,
norm
+
eps
)
return
am
return
am
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main.py
+
0
−
1
View file @
e7d9d6b3
...
@@ -15,7 +15,6 @@ checkpoint = utility.checkpoint(args)
...
@@ -15,7 +15,6 @@ checkpoint = utility.checkpoint(args)
check
=
utility
.
checkpoint
(
args
)
check
=
utility
.
checkpoint
(
args
)
teacher_model
=
model
.
Model
(
args
,
check
)
teacher_model
=
model
.
Model
(
args
,
check
)
#teacher_model.load_state_dict(torch.load('/home/iyj0121/AT_EDSR/model_best.pt'), strict=False)
teacher_model
.
load
(
apath
=
'
/home/iyj0121/AT_EDSR/
'
)
teacher_model
.
load
(
apath
=
'
/home/iyj0121/AT_EDSR/
'
)
teacher_model
.
eval
()
teacher_model
.
eval
()
...
...
This diff is collapsed.
Click to expand it.
src/trainer.py
+
1
−
3
View file @
e7d9d6b3
...
@@ -8,8 +8,6 @@ import torch
...
@@ -8,8 +8,6 @@ import torch
import
torch.nn.utils
as
utils
import
torch.nn.utils
as
utils
from
tqdm
import
tqdm
from
tqdm
import
tqdm
from
loss
import
at
class
Trainer
():
class
Trainer
():
def
__init__
(
self
,
args
,
loader
,
my_model
,
my_loss
,
ckp
,
teacher_model
,
kd_loss
):
def
__init__
(
self
,
args
,
loader
,
my_model
,
my_loss
,
ckp
,
teacher_model
,
kd_loss
):
self
.
args
=
args
self
.
args
=
args
...
@@ -53,7 +51,7 @@ class Trainer():
...
@@ -53,7 +51,7 @@ class Trainer():
with
torch
.
no_grad
():
with
torch
.
no_grad
():
t_res
,
_
=
self
.
t_model
(
lr
,
0
)
t_res
,
_
=
self
.
t_model
(
lr
,
0
)
kd_loss
=
self
.
KD_loss
(
res
,
t_res
)
kd_loss
=
self
.
KD_loss
(
res
,
t_res
)
loss
=
self
.
loss
(
sr
,
hr
)
+
0.
000
1
*
kd_loss
loss
=
self
.
loss
(
sr
,
hr
)
+
0.1
*
kd_loss
loss
.
backward
()
loss
.
backward
()
if
self
.
args
.
gclip
>
0
:
if
self
.
args
.
gclip
>
0
:
utils
.
clip_grad_value_
(
utils
.
clip_grad_value_
(
...
...
This diff is collapsed.
Click to expand it.
src/utility.py
+
2
−
2
View file @
e7d9d6b3
...
@@ -92,9 +92,9 @@ class checkpoint():
...
@@ -92,9 +92,9 @@ class checkpoint():
def
save
(
self
,
trainer
,
epoch
,
is_best
=
False
):
def
save
(
self
,
trainer
,
epoch
,
is_best
=
False
):
trainer
.
model
.
save
(
self
.
get_path
(
'
model
'
),
epoch
,
is_best
=
is_best
)
trainer
.
model
.
save
(
self
.
get_path
(
'
model
'
),
epoch
,
is_best
=
is_best
)
trainer
.
loss
.
save
(
self
.
dir
)
trainer
.
loss
.
save
(
self
.
dir
)
#
trainer.loss.plot_loss(self.dir, epoch)
trainer
.
loss
.
plot_loss
(
self
.
dir
,
epoch
)
#
self.plot_psnr(epoch)
self
.
plot_psnr
(
epoch
)
trainer
.
optimizer
.
save
(
self
.
dir
)
trainer
.
optimizer
.
save
(
self
.
dir
)
torch
.
save
(
self
.
log
,
self
.
get_path
(
'
psnr_log.pt
'
))
torch
.
save
(
self
.
log
,
self
.
get_path
(
'
psnr_log.pt
'
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment