This repository has been archived by the owner on Oct 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. fix预训练模型num_classes不一致出错问题
- Loading branch information
Showing
8 changed files
with
136 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea/ | ||
*.pyc | ||
outputs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
NUM_GPUS: 1 | ||
NUM_NODES: 1 | ||
RANK_ID: 0 | ||
DIST_BACKEND: "nccl" | ||
RNG_SEED: 1 | ||
OUTPUT_DIR: 'outputs/r50_custom_pretrained_cifar100_224' | ||
TRAIN: | ||
LOG_STEP: 10 | ||
MAX_EPOCH: 200 | ||
SAVE_EPOCH: 5 | ||
EVAL_EPOCH: 5 | ||
RESUME: False | ||
USE_TENSORBOARD: True | ||
DATASET: | ||
NAME: 'CIFAR100' | ||
DATA_DIR: './data/cifar' | ||
TRANSFORM: | ||
MEAN: (0.5071, 0.4865, 0.4409) | ||
STD: (0.1942, 0.1918, 0.1958) | ||
TRAIN: | ||
SHORTER_SIDE: 224 | ||
CENTER_CROP: True | ||
TRAIN_CROP_SIZE: 224 | ||
TEST: | ||
SHORTER_SIDE: 224 | ||
CENTER_CROP: True | ||
TEST_CROP_SIZE: 224 | ||
DATALOADER: | ||
TRAIN_BATCH_SIZE: 96 | ||
TEST_BATCH_SIZE: 96 | ||
NUM_WORKERS: 8 | ||
MODEL: | ||
NAME: 'ResNet' | ||
PRETRAINED: '' | ||
TORCHVISION_PRETRAINED: True | ||
SYNC_BN: False | ||
BACKBONE: | ||
ARCH: 'resnet50' | ||
HEAD: | ||
FEATURE_DIMS: 2048 | ||
NUM_CLASSES: 100 | ||
RECOGNIZER: | ||
NAME: 'ResNet_Custom' | ||
CRITERION: | ||
NAME: 'CrossEntropyLoss' | ||
OPTIMIZER: | ||
NAME: 'SGD' | ||
LR: 1e-3 | ||
WEIGHT_DECAY: 1e-5 | ||
SGD: | ||
MOMENTUM: 0.9 | ||
LR_SCHEDULER: | ||
NAME: 'MultiStepLR' | ||
IS_WARMUP: True | ||
GAMMA: 0.1 | ||
MULTISTEP_LR: | ||
MILESTONES: [ 100, 150, 175 ] | ||
WARMUP: | ||
ITERATION: 5 | ||
MULTIPLIER: 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
@date: 2020/11/26 下午10:47 | ||
@file: init_helper.py | ||
@author: zj | ||
@description: | ||
""" | ||
|
||
import math | ||
from torch.nn import init | ||
|
||
|
||
def reset_parameters(layer) -> None: | ||
init.kaiming_uniform_(layer.weight, a=math.sqrt(5)) | ||
if layer.bias is not None: | ||
fan_in, _ = init._calculate_fan_in_and_fan_out(layer.weight) | ||
bound = 1 / math.sqrt(fan_in) | ||
init.uniform_(layer.bias, -bound, bound) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters