Skip to content

Commit

Permalink
feat(BeitV2): remove print and modify yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
oozhuzaioo committed May 18, 2023
1 parent d9b56ca commit 412ec1d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 43 deletions.
1 change: 0 additions & 1 deletion ppcls/arch/backbone/model_zoo/vqkd.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def __init__(self,
**kwargs
):
super().__init__()
print(kwargs)
if decoder_config['in_chans'] != embed_dim:
print(f"Rewrite the in_chans in decoder from {decoder_config['in_chans']} to {embed_dim}")
decoder_config['in_chans'] = embed_dim
Expand Down
11 changes: 9 additions & 2 deletions ppcls/configs/ImageNet/BeitV2/BeitV2_base_patch16_224_ft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Global:
pretrained_model: null
output_dir: ./output/
device: gpu
save_interval: 50
save_interval: 1
eval_during_train: True
eval_interval: 1
epochs: 100
Expand All @@ -15,7 +15,14 @@ Global:
save_inference_dir: ./inference
to_static: False
seed: 0
distributed: 4
distributed: 8

AMP:
scale_loss: 65536.0
use_dynamic_loss_scaling: True
incr_every_n_steps: 2000
# O1: mixed fp16
level: O1

# model architecture
Arch:
Expand Down
48 changes: 10 additions & 38 deletions ppcls/configs/ImageNet/BeitV2/BeitV2_base_patch16_224_pt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Global:
checkpoints: null
pretrained_model: null
output_dir: ./output/beitv2_clip_dist
output_dir: ./output/
device: gpu
save_interval: 1
eval_during_train: False
Expand All @@ -16,7 +16,7 @@ Global:
save_inference_dir: ./inference
to_static: False
seed: 0
distributed: 4
distributed: 8

AMP:
scale_loss: 65536.0
Expand All @@ -29,7 +29,7 @@ AMP:
Arch:
name: "Beitv2Model"
drop_path_rate : 0.1
class_num: &class_num 1000
class_num: 1000
is_beitv2: True
# if not null, its lengths should be same as models
pretrained_list:
Expand All @@ -42,15 +42,15 @@ Arch:
- Teacher:
name: vqkd_encoder_base_decoder_3x768x12_clip
pretrained: True
pretrained_weight: /home/aistudio/weight/vqkd.pdparams
pretrained_weight: ./dataset/vqkd.pdparams
as_tokenzer: False
img_size: 224
n_code: 8192
code_dim: 32
- Student:
name: beit_base_patch16_224_8k_vocab_cls_pt
pretrained: True
pretrained_weight: /home/aistudio/weight/pretrain_model.pdparams
pretrained_weight: ./dataset/pretrain_model.pdparams
drop_path_rate: 0.1
use_shared_rel_pos_bias: True
use_abs_pos_emb: False
Expand All @@ -75,14 +75,14 @@ Optimizer:
beta1: 0.9
beta2: 0.98
momentum: 0.9
weight_decay: 1e-4
epsilon: 1e-8
weight_decay: 0.05
#multi precision: True
no_weight_decay_name: pos_embed cls_token .bias norm gamma
one_dim_param_no_weight_decay: True
# Ir自定义
lr:
name: Cosine
learning_rate: 0.0015
learning_rate: 1.5e-3
T_max: 200
eta_min: 1e-5
warmup_steps: 10
Expand All @@ -94,8 +94,8 @@ DataLoader:
Train:
dataset:
name: BEiT_ImageNet
image_root: /home/aistudio/data/data89857/ILSVRC2012mini/
cls_label_path: /home/aistudio/data/data89857/ILSVRC2012mini/train_list.txt
image_root: ./dataset/ILSVRC2012/
cls_label_path: ./dataset/ILSVRC2012/train_list.txt
transform_ops:
- DecodeImage:
to_rgb: True,
Expand Down Expand Up @@ -135,31 +135,3 @@ DataLoader:
loader:
num_workers: 4
use_shared_memory: True

Eval:
dataset:
name: ImageNetDataset
image_root: /home/aistudio/data/data89857/ILSVRC2012mini/val/
cls_label_path: /home/aistudio/data/data89857/ILSVRC2012mini/val_list.txt
transform_ops:
- DecodeImage:
to_rgb: True
channel_first: False
- ResizeImage:
resize_short: 256
- CropImage:
size: 224
- NormalizeImage:
scale: 1.0/255.0
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
sampler:
name: DistributedBatchSampler
batch_size: 256
drop_last: False
shuffle: False
loader:
num_workers: 8
use_shared_memory: True

3 changes: 2 additions & 1 deletion ppcls/engine/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def train_epoch(engine, epoch_id, print_batch_step):
scaled.backward()
if (iter_id + 1) % engine.update_freq == 0:
for i in range(len(engine.optimizer)):
engine.scaler.minimize(engine.optimizer[i], scaled)
engine.scaler.step(engine.optimizer[i])
engine.scaler.update()
else:
loss.backward()
if (iter_id + 1) % engine.update_freq == 0:
Expand Down
1 change: 0 additions & 1 deletion ppcls/optimizer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ def _get_parameter_groups(self, model, weight_decay=0.05, skip_list=(), get_num_
parameter_group_names = {}
parameter_group_vars = {}
for name, param in model.named_parameters():
print(param.stop_gradient)
if param.stop_gradient:
continue

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ scikit-learn>=0.21.0
gast==0.3.3
faiss-cpu
easydict
einops

0 comments on commit 412ec1d

Please sign in to comment.