swin_transformer_v2训练异常,训练初期loss就基本不下降,求指导(自定义数据集) #1961
Unanswered
xiaojing-stu
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
数据集是自定义的 已经按官方格式构造了,如图1;
<img width="874" alt="classes" src="https://github.com/user-attachments/assets/d033161a-963f-4d2b-96c2-dae577c3c000" />
模型是swinv2-base-w12_3rdparty_in21k-192px_20220803-f7dc9763.pth,没有改网络结构,是配置问题吗,已经调整了lr 从0.00025到0.1 还是不对。
配置文件如下:
`auto_scale_lr = dict(base_batch_size=1024)
checkpoint_config = dict(by_epoch=True, interval=10, max_keep_ckpts=3)
data_preprocessor = dict(
mean=[
123.675,
116.28,
103.53,
],
num_classes=6,
std=[
58.395,
57.12,
57.375,
],
to_rgb=True)
dataset_type = 'CustomDataset'
default_hooks = dict(
checkpoint=dict(interval=10, type='CheckpointHook'),
logger=dict(interval=100, type='LoggerHook'),
param_scheduler=dict(type='ParamSchedulerHook'),
sampler_seed=dict(type='DistSamplerSeedHook'),
timer=dict(type='IterTimerHook'),
visualization=dict(enable=False, type='VisualizationHook'))
default_scope = 'mmpretrain'
env_cfg = dict(
cudnn_benchmark=False,
dist_cfg=dict(backend='nccl'),
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
img_norm_cfg = dict(
mean=[
123.675,
116.28,
103.53,
], std=[
58.395,
57.12,
57.375,
])
launcher = 'pytorch'
load_from = None
log_level = 'INFO'
model = dict(
backbone=dict(
arch='base',
drop_path_rate=0.5,
img_size=512,
pad_small_map=True,
type='SwinTransformerV2',
window_size=[
12,
12,
12,
6,
]),
head=dict(
cal_acc=False,
in_channels=1024,
init_cfg=None,
loss=dict(
label_smooth_val=0.1, mode='original', type='LabelSmoothLoss'),
num_classes=6,
type='LinearClsHead'),
init_cfg=[
dict(bias=0.0, layer='Linear', std=0.02, type='TruncNormal'),
dict(bias=0.0, layer='LayerNorm', type='Constant', val=1.0),
],
neck=dict(type='GlobalAveragePooling'),
train_cfg=dict(augments=None),
type='ImageClassifier')
optim_wrapper = dict(
optimizer=dict(
betas=(
0.9,
0.999,
),
eps=1e-08,
lr=0.1,
type='AdamW',
weight_decay=0.05),
paramwise_cfg=dict(
bias_decay_mult=0.0,
custom_keys=dict({
'.absolute_pos_embed': dict(decay_mult=0.0),
'.relative_position_bias_table': dict(decay_mult=0.0)
}),
flat_decay_mult=0.0,
norm_decay_mult=0.0))
param_scheduler = [
dict(
by_epoch=True,
convert_to_iter_based=True,
end=1,
start_factor=0.01,
type='LinearLR'),
dict(begin=1, by_epoch=True, eta_min=1e-05, type='CosineAnnealingLR'),
]
pretrained = '/root/paddlejob/workspace/gengxiaojing/Detect_Model/model/models/swinv2-base-w12_3rdparty_in21k-192px_20220803-f7dc9763.pth'
randomness = dict(deterministic=False, seed=None)
resume = False
test_cfg = dict()
test_dataloader = dict(
batch_size=8,
collate_fn=dict(type='default_collate'),
dataset=dict(
data_root=
'/root/paddlejob/workspace/gengxiaojing/Detect_Model/datasets/zhongce_datasets/train_slice_classes/test',
pipeline=[
dict(type='LoadImageFromFile'),
dict(scale=512, type='Resize'),
dict(type='PackInputs'),
],
type='CustomDataset'),
num_workers=1,
persistent_workers=True,
pin_memory=True)
test_evaluator = dict(
topk=(
1,
5,
), type='Accuracy')
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(scale=512, type='Resize'),
dict(type='PackInputs'),
]
train_cfg = dict(by_epoch=True, max_epochs=70, val_interval=5)
train_dataloader = dict(
batch_size=8,
collate_fn=dict(type='default_collate'),
dataset=dict(
data_root=
'/root/paddlejob/workspace/gengxiaojing/Detect_Model/datasets/zhongce_datasets/train_slice_classes/train',
pipeline=[
dict(type='LoadImageFromFile'),
dict(
prob=0.5,
transforms=[
dict(
brightness=0.5,
contrast=0.5,
hue=0.2,
saturation=0.5,
type='ColorJitter'),
dict(magnitude_range=(
-10,
10,
), type='Rotate'),
],
type='RandomApply'),
dict(scale=512, type='Resize'),
dict(type='PackInputs'),
],
type='CustomDataset'),
num_workers=1,
persistent_workers=True,
pin_memory=True,
sampler=dict(shuffle=True, type='DefaultSampler'))
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
prob=0.5,
transforms=[
dict(
brightness=0.5,
contrast=0.5,
hue=0.2,
saturation=0.5,
type='ColorJitter'),
dict(magnitude_range=(
-10,
10,
), type='Rotate'),
],
type='RandomApply'),
dict(scale=512, type='Resize'),
dict(type='PackInputs'),
]
val_cfg = dict()
val_dataloader = dict(
batch_size=8,
collate_fn=dict(type='default_collate'),
dataset=dict(
data_root=
'/root/paddlejob/workspace/gengxiaojing/Detect_Model/datasets/zhongce_datasets/train_slice_classes/val',
pipeline=[
dict(type='LoadImageFromFile'),
dict(scale=512, type='Resize'),
dict(type='PackInputs'),
],
type='CustomDataset'),
num_workers=1,
persistent_workers=True,
pin_memory=True)
val_evaluator = dict(
topk=(
1,
5,
), type='Accuracy')
vis_backends = [
dict(type='LocalVisBackend'),
]
visualizer = dict(
type='UniversalVisualizer', vis_backends=[
dict(type='LocalVisBackend'),
])
work_dir = './work_dirs/swinv2-base-w12_3rdparty_in21k-192px_20220803-f7dc9763'
`
训练结果如下:
Beta Was this translation helpful? Give feedback.
All reactions