Skip to content

Commit

Permalink
add dropout, channel dropout, increase number of epoch to 50
Browse files Browse the repository at this point in the history
  • Loading branch information
triducnguyentang committed Jul 19, 2019
1 parent eea231f commit 059ba34
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 33 deletions.
4 changes: 2 additions & 2 deletions bin/train.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

export CUDA_VISIBLE_DEVICES=2,3
export CUDA_VISIBLE_DEVICES=0,1,2,3
RUN_CONFIG=config.yml


LOGDIR=/raid/bac/kaggle/logs/recursion_cell/test/c1234_s1_affine_warmup/se_resnext50_32x4d/
LOGDIR=./bin/30_epochs/
catalyst-dl run \
--config=./configs/${RUN_CONFIG} \
--logdir=$LOGDIR \
Expand Down
53 changes: 45 additions & 8 deletions configs/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ stages:

data_params:
batch_size: 64
num_workers: 8
num_workers: 16
drop_last: False
# drop_last: True

image_size: &image_size 512
train_csv: "./csv/train_0.csv"
valid_csv: "./csv/valid_0.csv"
root: "/raid/data/kaggle/recursion-cellular-image-classification/"
root: "./data/"
sites: [1]
channels: [1, 2, 3, 4]

##################################################
stage0:

optimizer_params:
Expand Down Expand Up @@ -63,7 +64,7 @@ stages:
reduce_metric: *reduce_metric
saver:
callback: CheckpointCallback

##########################################################
stage1:

optimizer_params:
Expand All @@ -72,12 +73,48 @@ stages:

scheduler_params:
scheduler: OneCycleLR
num_steps: &num_epochs 30
num_steps: 50
lr_range: [0.0005, 0.00001]
# lr_range: [0.0015, 0.00003]
warmup_steps: 5
momentum_range: [0.85, 0.95]

state_params:
num_epochs: *num_epochs

callbacks_params: *callback_params
num_epochs: 50

callbacks_params: *callback_params
######################################################
# stage2:

# optimizer_params:
# optimizer: Nadam
# lr: 0.00001

# scheduler_params:
# scheduler: ReduceLROnPlateau
# patience: 2
# # num_steps: 30
# # lr_range: [0.0007, 0.00001]
# # warmup_steps: 0
# # momentum_range: [0.85, 0.95]

# state_params:
# num_epochs: 10

# criterion_params:
# criterion: LabelSmoothingCrossEntropy

# callbacks_params:
# loss:
# callback: LabelSmoothCriterionCallback
# optimizer:
# callback: OptimizerCallback
# accumulation_steps: 2
# accuracy:
# callback: AccuracyCallback
# accuracy_args: [1]
# scheduler:
# callback: SchedulerCallback
# reduce_metric: *reduce_metric
# saver:
# callback: CheckpointCallback
30 changes: 16 additions & 14 deletions src/augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@


def train_aug(image_size=224):
policies = './csv/best_policy.data'
with open(policies, 'r') as fid:
policies = eval(fid.read())
policies = itertools.chain.from_iterable(policies)

aug_list = []
for policy in policies:
op_1, params_1 = policy[0]
op_2, params_2 = policy[1]
aug = Compose([
globals().get(op_1)(**params_1),
globals().get(op_2)(**params_2),
])
aug_list.append(aug)
# policies = './csv/best_policy.data'
# with open(policies, 'r') as fid:
# policies = eval(fid.read())
# policies = itertools.chain.from_iterable(policies)

# aug_list = []
# for policy in policies:
# op_1, params_1 = policy[0]
# op_2, params_2 = policy[1]
# aug = Compose([
# globals().get(op_1)(**params_1),
# globals().get(op_2)(**params_2),
# ])
# aug_list.append(aug)

return Compose([
ChannelDropout(),
# CLAHE(),
RandomRotate90(),
Flip(),
Transpose(),
Expand Down
18 changes: 9 additions & 9 deletions src/make_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def predict(model, loader):


def predict_all():
test_csv = '/raid/data/kaggle/recursion-cellular-image-classification/test.csv'
test_csv = './data/test.csv'
# test_csv = './csv/valid_0.csv'

for fold in [0, 1, 2, 3]:
for fold in [0,1,2,3,4]:
model_name = 'se_resnext50_32x4d'

log_dir = f"/raid/bac/kaggle/logs/recursion_cell/search_channels/fold_{fold}/[1,2,3,4]/se_resnext50_32x4d/"
root = "/raid/data/kaggle/recursion-cellular-image-classification/"
log_dir = f"./bin/log/checkpoints/"
root = "./data/"
sites = [1]
channels = [1,2,3,4]

Expand Down Expand Up @@ -73,7 +73,7 @@ def predict_all():
dataset=dataset,
batch_size=128,
shuffle=False,
num_workers=4,
num_workers=12,
)

pred = predict(model, loader)
Expand All @@ -90,14 +90,14 @@ def predict_all():


def predict_one():
test_csv = '/raid/data/kaggle/recursion-cellular-image-classification/test.csv'
test_csv = './data/test.csv'
# test_csv = './csv/valid_0.csv'

model_name = 'se_resnext50_32x4d'
experiment = "c1234_s1_affine_warmup"
experiment = "dropout_channel"

log_dir = f"/raid/bac/kaggle/logs/recursion_cell/test/{experiment}/{model_name}/"
root = "/raid/data/kaggle/recursion-cellular-image-classification/"
log_dir = f"./bin/log/"
root = "./data/"
sites = [1]
channels = [1,2,3,4]

Expand Down
1 change: 1 addition & 0 deletions src/models/senet.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def cell_senet(model_name='se_resnext50_32x4d', num_classes=1108, n_channels=6):
pretrained=True,
# pool=GlobalConcatPool2d(),
# classifier_factory=make_classifier
dropout_p=0.3
)
# print(model)
conv1 = model._features[0].conv1
Expand Down

0 comments on commit 059ba34

Please sign in to comment.