model_params:
  model: &model CNNFinetuneModels
  model_name: &model_name resnet50
  num_classes: 6


args:
  expdir: "src"
  logdir: &logdir "./logs/rsna"
  baselogdir: "./logs/rsna"

distributed_params:
  opt_level: O1

stages:

  state_params:
    main_metric: &reduce_metric loss
    minimize_metric: True

  criterion_params:
    criterion: &criterion LogLoss
    weight: [1,1,1,1,1,2]

  data_params:
    batch_size: 64
    num_workers: 4
    drop_last: False

    train_csv: "./csv/stratified_kfold/train_0.csv.gz"
    valid_csv: "./csv/stratified_kfold/valid_0.csv.gz"
    with_any: True
#    root: "/data/stage_1_train_3w/"
#    image_type: "jpg"

    root: "/data/png/train/adjacent-brain-cropped/"
    image_type: "png"
    normalization: False

  callbacks_params: &callbacks_params
    loss:
      callback: CriterionCallback
    optimizer:
      callback: OptimizerCallback
      accumulation_steps: 1
    scheduler:
      callback: SchedulerCallback
      reduce_metric: *reduce_metric
    saver:
      callback: CheckpointCallback
      save_n_best: 5
    early_stoping:
      callback: EarlyStoppingCallback
      patience: 2


  warmup:
    data_params:
      image_size: [512, 512]

    optimizer_params:
      optimizer: AdamW
      lr: 0.001

    scheduler_params:
      scheduler: MultiStepLR
      milestones: [10]
      gamma: 0.3

    state_params:
      num_epochs: 3

    callbacks_params:
      loss:
        callback: CriterionCallback
      optimizer:
        callback: OptimizerCallback
        accumulation_steps: 1
      scheduler:
        callback: SchedulerCallback
        reduce_metric: *reduce_metric
      saver:
        callback: CheckpointCallback
        save_n_best: 5
      early_stoping:
        callback: EarlyStoppingCallback
        patience: 3

  train512:

    data_params:
      image_size: [512, 512]

    optimizer_params:
      optimizer: AdamW
      lr: 0.0001

    scheduler_params:
#      scheduler: MultiStepLR
#      milestones: [3]
#      gamma: 0.1
      scheduler: ReduceLROnPlateau
      patience: 0
      min_lr: 0.00001

    state_params:
      num_epochs: 20

    callbacks_params:
      loss:
        callback: CriterionCallback
      optimizer:
        callback: OptimizerCallback
        accumulation_steps: 1
      scheduler:
        callback: SchedulerCallback
        reduce_metric: *reduce_metric
      saver:
        callback: CheckpointCallback
        save_n_best: 5
      early_stoping:
        callback: EarlyStoppingCallback
        patience: 3
#        metric: "accuracy01"
#        minimize: False

    # callbacks_params: *callbacks_params

monitoring_params:
  project: "Kaggle-RSNA"
  tags: [*model, *model_name, *criterion]