-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ViTs #3
Conversation
TODO: update numbers
also remove todo
] | ||
|
||
baseline = { | ||
f"{name}": update_default( | ||
dict( | ||
data=dict( | ||
batch_size=DEFAULT_BATCH_SIZE | ||
if "_l_" not in name and "simple_vit_b" not in name | ||
else DEFAULT_BATCH_SIZE // 2, | ||
train_transform=ImageNetClassificationPresetTrain( | ||
crop_size=DEFAULT_CROP_SIZE, | ||
auto_augment_policy="ra", | ||
ra_magnitude=10, | ||
is_bcos=False, | ||
), | ||
test_transform=ImageNetClassificationPresetEval( | ||
crop_size=DEFAULT_CROP_SIZE, | ||
is_bcos=False, | ||
), | ||
), | ||
model=dict( | ||
is_bcos=False, | ||
name=name, | ||
args=dict( | ||
# linear_layer and conv2d_layer set by model.py | ||
norm_layer=nn.LayerNorm, | ||
norm2d_layer=DetachableGNLayerNorm2d, | ||
act_layer=nn.GELU, | ||
channels=3, | ||
), | ||
), | ||
criterion=nn.CrossEntropyLoss(), | ||
test_criterion=nn.CrossEntropyLoss(), | ||
optimizer=OptimizerFactory( | ||
"AdamW", | ||
lr=DEFAULT_LR, | ||
weight_decay=0.0001, | ||
), | ||
use_agc=False, | ||
lr_scheduler=DEFAULT_LR_SCHEDULE | ||
if "_l_" not in name and "simple_vit_b" not in name | ||
else LONG_WARM_SCHEDULE, | ||
trainer=dict( | ||
gradient_clip_val=1.0, | ||
), | ||
) | ||
) | ||
for name in SIMPLE_VIT_ARCHS | ||
} | ||
|
||
|
||
bcos = { | ||
f"bcos_{name}": update_default( | ||
dict( | ||
data=dict( | ||
batch_size=DEFAULT_BATCH_SIZE | ||
if "_l_" not in name and "simple_vit_b" not in name | ||
else DEFAULT_BATCH_SIZE // 2, | ||
train_transform=ImageNetClassificationPresetTrain( | ||
crop_size=DEFAULT_CROP_SIZE, | ||
auto_augment_policy="ra", | ||
ra_magnitude=10, | ||
is_bcos=True, | ||
), | ||
test_transform=ImageNetClassificationPresetEval( | ||
crop_size=DEFAULT_CROP_SIZE, | ||
is_bcos=True, | ||
), | ||
num_workers=10, | ||
), | ||
model=dict( | ||
is_bcos=True, | ||
name=name, | ||
args=dict( | ||
# linear_layer and conv2d_layer set by model.py | ||
norm_layer=norms.NoBias(norms.DetachableLayerNorm), | ||
act_layer=nn.Identity, | ||
channels=6, | ||
norm2d_layer=norms.NoBias(DetachableGNLayerNorm2d), | ||
), | ||
bcos_args=dict( | ||
b=2, | ||
max_out=1, | ||
), | ||
logit_bias=math.log(1 / (NUM_CLASSES - 1)), | ||
), | ||
criterion=UniformOffLabelsBCEWithLogitsLoss(), | ||
lr_scheduler=DEFAULT_LR_SCHEDULE | ||
if "_l_" not in name and "simple_vit_b" not in name | ||
else LONG_WARM_SCHEDULE, | ||
test_criterion=BinaryCrossEntropyLoss(), | ||
optimizer=OptimizerFactory( | ||
"Adam", | ||
lr=DEFAULT_LR, | ||
), | ||
) | ||
) | ||
for name in SIMPLE_VIT_ARCHS | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using something like the following in the configs, might be a bit cleaner:
is_big_model = lambda model_name: "_l_" in model_name or "simple_vit_b" in model_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, much more readable. I'll push a change. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, minor questions / comments, what do you think?
Co-authored-by: moboehle <moritzboehle@me.com>
Co-authored-by: moboehle <moritzboehle@me.com>
Great suggestions and nice catch! I'll merge and then finish the release. Thanks for taking a look! 😃 |
@moboehle take a look please! :)
(You can ignore the
pretrained.py
andREADME.md
files.)I'll merge it if everything looks good and then finish it up as the
v0.1.0
release