Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
test_on_pytorch
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
0a93c10d
authored
2022-12-12 19:00:34 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
d865f629
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
7 deletions
config/vit.yaml
model/builder.py
model/vit.py
solver/builder.py
config/vit.yaml
View file @
0a93c10
...
...
@@ -22,17 +22,18 @@ model:
num_classes
:
5
embed_dim
:
8
depth
:
12
num_heads
:
1
2
num_heads
:
2
mlp_ratio
:
4.0
qkv_bias
:
true
qk_scale
:
n
one
representation_size
:
n
one
qk_scale
:
n
ull
representation_size
:
n
ull
distilled
:
false
drop_ratio
:
0.
attn_drop_ratio
:
0.
drop_path_ratio
:
0.
norm_layer
:
none
act_layer
:
none
norm_layer
:
null
act_layer
:
null
input_length
:
29
solver
:
name
:
'
VITSolver'
...
...
model/builder.py
View file @
0a93c10
...
...
@@ -2,6 +2,7 @@ import copy
from
utils
import
MODEL_REGISTRY
from
.mlp
import
MLPModel
from
.vit
import
VisionTransformer
def
build_model
(
cfg
):
...
...
model/vit.py
View file @
0a93c10
...
...
@@ -182,7 +182,7 @@ class VisionTransformer(nn.Module):
embed_dim
=
768
,
depth
=
12
,
num_heads
=
12
,
mlp_ratio
=
4.0
,
qkv_bias
=
True
,
qk_scale
=
None
,
representation_size
=
None
,
distilled
=
False
,
drop_ratio
=
0.
,
attn_drop_ratio
=
0.
,
drop_path_ratio
=
0.
,
embed_layer
=
PatchEmbed
,
norm_layer
=
None
,
act_layer
=
None
):
act_layer
=
None
,
input_length
=
29
):
"""
Args:
img_size (int, tuple): input image size
...
...
@@ -215,7 +215,8 @@ class VisionTransformer(nn.Module):
self
.
cls_token
=
nn
.
Parameter
(
torch
.
zeros
(
1
,
1
,
embed_dim
))
self
.
dist_token
=
nn
.
Parameter
(
torch
.
zeros
(
1
,
1
,
embed_dim
))
if
distilled
else
None
self
.
pos_embed
=
nn
.
Parameter
(
torch
.
zeros
(
1
,
num_patches
+
self
.
num_tokens
,
embed_dim
))
# self.pos_embed = nn.Parameter(torch.zeros(1, num_patches + self.num_tokens, embed_dim))
self
.
pos_embed
=
nn
.
Parameter
(
torch
.
zeros
(
1
,
input_length
+
self
.
num_tokens
,
embed_dim
))
self
.
pos_drop
=
nn
.
Dropout
(
p
=
drop_ratio
)
dpr
=
[
x
.
item
()
for
x
in
torch
.
linspace
(
0
,
drop_path_ratio
,
depth
)]
# stochastic depth decay rule
...
...
solver/builder.py
View file @
0a93c10
...
...
@@ -2,6 +2,7 @@ import copy
from
utils.registery
import
SOLVER_REGISTRY
from
.mlp_solver
import
MLPSolver
from
.vit_solver
import
VITSolver
def
build_solver
(
cfg
):
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment