{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c812e9f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "#!pip3 install --upgrade pip setuptools wheel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "3c2f5cb0",
   "metadata": {},
   "outputs": [],
   "source": [
    "!chmod +x eval.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9808149e",
   "metadata": {},
   "outputs": [],
   "source": [
    "#setup\n",
    "!git clone https://github.com/NVIDIA/apex\n",
    "!cp /home/feoktistovar67431/git/apex/setup.py .\n",
    "!pip3 install -v --disable-pip-version-check --no-cache-dir ./\n",
    "!pip install git+https://github.com/ildoonet/pytorch-gradual-warmup-lr.git\n",
    "!python3 -m pip install torch torchvision scikit-learn tensorboard diffdist==0.1 tensorboardX torchlars==0.1.2 apex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf0756e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "\n",
    "print(f\"Is CUDA supported by this system? ->{torch.cuda.is_available()}\")\n",
    "print(f\"CUDA version: {torch.version.cuda}\")\n",
    "cuda_id = torch.cuda.current_device()\n",
    "print(f\"ID of current CUDA device: {torch.cuda.current_device()}\")\n",
    "print(f\"Number of available devices: {torch.cuda.device_count()}\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f7ff35c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#TEST ONLY\n",
    "#!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 '/home/feoktistovar67431/CSI/CSI/train.py' --dataset 'cifar10' --model 'resnet18' --mode simclr_CSI --shift_trans_type rotation --epochs 10 --batch_size 32 --optimizer sgd --one_class_idx 9"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3f0081b",
   "metadata": {},
   "source": [
    "# Combined shiftings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "id": "26921f38",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/feoktistovar67431/.local/lib/python3.6/site-packages/torch/distributed/launch.py:186: FutureWarning: The module torch.distributed.launch is deprecated\n",
      "and will be removed in future. Use torchrun.\n",
      "Note that --use_env is set by default in torchrun.\n",
      "If your script expects `--local_rank` argument to be set, please\n",
      "change it to read from `os.environ['LOCAL_RANK']` instead. See \n",
      "https://pytorch.org/docs/stable/distributed.html#launch-utility for \n",
      "further instructions\n",
      "\n",
      "  FutureWarning,\n",
      "WARNING:torch.distributed.run:\n",
      "*****************************************\n",
      "Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. \n",
      "*****************************************\n",
      "Warning:  using Python fallback for SyncBatchNorm, possibly because apex was installed without --cuda_ext.  The exception raised when attempting to import the cuda backend was:  No module named 'syncbn'\n",
      "Warning:  using Python fallback for SyncBatchNorm, possibly because apex was installed without --cuda_ext.  The exception raised when attempting to import the cuda backend was:  No module named 'syncbn'\n",
      "Warning:  apex was installed without --cpp_ext.  Falling back to Python flatten and unflatten.\n",
      "Warning:  apex was installed without --cpp_ext.  Falling back to Python flatten and unflatten.\n",
      "[2022-04-27 21:19:03.912343] Namespace(K_shift=4, batch_size=8, blur_sigma=40.0, color_distort=0.5, dataset='CNMC', distortion_scale=0.8, epochs=10, error_step=5, image_size=(300, 300, 3), load_path=None, local_rank=0, lr_init=0.1, lr_scheduler='cosine', mode='simclr_CSI', model='resnet18_imagenet', multi_gpu=True, n_classes=2, n_gpus=2, n_superclasses=2, no_strict=False, noise_mean=0, noise_std=0.3, one_class_idx=1, ood_batch_size=100, ood_dataset=[0], ood_layer='simclr', ood_samples=1, ood_score=['norm_mean'], optimizer='sgd', print_score=False, proc_step=None, res='450px', resize_factor=0.08, resize_fix=False, resume_path=None, save_score=False, save_step=10, sharpness_factor=2, shift_trans=BlurRandpers(\n",
      "  (gauss): GaussBlur()\n",
      "  (randpers): RandPers()\n",
      "), shift_trans_type='blur_randpers', sim_lambda=1.0, simclr_dim=128, suffix=None, temperature=0.5, test_batch_size=100, warmup=10, weight_decay=1e-06)\n",
      "[2022-04-27 21:19:03.912780] DistributedDataParallel(\n",
      "  (module): ResNet(\n",
      "    (linear): Linear(in_features=512, out_features=2, bias=True)\n",
      "    (simclr_layer): Sequential(\n",
      "      (0): Linear(in_features=512, out_features=512, bias=True)\n",
      "      (1): ReLU()\n",
      "      (2): Linear(in_features=512, out_features=128, bias=True)\n",
      "    )\n",
      "    (shift_cls_layer): Linear(in_features=512, out_features=4, bias=True)\n",
      "    (joint_distribution_layer): Linear(in_features=512, out_features=8, bias=True)\n",
      "    (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)\n",
      "    (bn1): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "    (relu): ReLU(inplace=True)\n",
      "    (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n",
      "    (layer1): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (layer2): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (downsample): Sequential(\n",
      "          (0): Conv2d(64, 128, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
      "          (1): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        )\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (layer3): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (downsample): Sequential(\n",
      "          (0): Conv2d(128, 256, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
      "          (1): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        )\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (layer4): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (downsample): Sequential(\n",
      "          (0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
      "          (1): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        )\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (avgpool): AdaptiveAvgPool2d(output_size=(1, 1))\n",
      "    (normalize): NormalizeLayer()\n",
      "  )\n",
      ")\n",
      "Epoch 1 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "/home/feoktistovar67431/.local/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:154: UserWarning: The epoch parameter in `scheduler.step()` was not necessary and is being deprecated where possible. Please use `scheduler.step()` to step the scheduler. During the deprecation, if epoch is different from None, the closed form is used instead of the new chainable form, where available. Please open an issue if you are unable to replicate your use case: https://github.com/pytorch/pytorch/issues/new/choose.\n",
      "  warnings.warn(EPOCH_DEPRECATION_WARNING, UserWarning)\n",
      "/home/feoktistovar67431/.local/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:154: UserWarning: The epoch parameter in `scheduler.step()` was not necessary and is being deprecated where possible. Please use `scheduler.step()` to step the scheduler. During the deprecation, if epoch is different from None, the closed form is used instead of the new chainable form, where available. Please open an issue if you are unable to replicate your use case: https://github.com/pytorch/pytorch/issues/new/choose.\n",
      "  warnings.warn(EPOCH_DEPRECATION_WARNING, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2022-04-27 21:19:06.681133] [Epoch   1;   0] [Time 1.753] [Data 0.128] [LR 0.10000]\n",
      "[LossC 0.000000] [LossSim 4.795710] [LossShift 1.446792]\n",
      "[2022-04-27 21:19:26.588634] [Epoch   1;  50] [Time 0.435] [Data 0.827] [LR 0.11004]\n",
      "[LossC 0.000000] [LossSim 4.458384] [LossShift 1.450558]\n",
      "[2022-04-27 21:19:47.065503] [Epoch   1; 100] [Time 0.441] [Data 0.818] [LR 0.12009]\n",
      "[LossC 0.000000] [LossSim 4.495318] [LossShift 0.887940]\n",
      "[2022-04-27 21:20:08.001796] [Epoch   1; 150] [Time 0.451] [Data 0.826] [LR 0.13013]\n",
      "[LossC 0.000000] [LossSim 4.466498] [LossShift 1.651758]\n",
      "[2022-04-27 21:20:29.557696] [Epoch   1; 200] [Time 0.463] [Data 0.859] [LR 0.14018]\n",
      "[LossC 0.000000] [LossSim 4.488340] [LossShift 0.890679]\n",
      "[2022-04-27 21:20:51.522911] [Epoch   1; 250] [Time 0.465] [Data 0.987] [LR 0.15022]\n",
      "[LossC 0.000000] [LossSim 4.457443] [LossShift 1.463503]\n",
      "[2022-04-27 21:21:13.774301] [Epoch   1; 300] [Time 0.481] [Data 0.873] [LR 0.16027]\n",
      "[LossC 0.000000] [LossSim 4.408203] [LossShift 0.978724]\n",
      "[2022-04-27 21:21:36.139558] [Epoch   1; 350] [Time 0.463] [Data 0.896] [LR 0.17031]\n",
      "[LossC 0.000000] [LossSim 4.406531] [LossShift 0.853714]\n",
      "[2022-04-27 21:21:58.598135] [Epoch   1; 400] [Time 0.469] [Data 0.870] [LR 0.18036]\n",
      "[LossC 0.000000] [LossSim 4.494049] [LossShift 0.970959]\n",
      "[2022-04-27 21:22:19.114742] [DONE] [Time 0.471] [Data 0.868] [LossC 0.000000] [LossSim 4.517576] [LossShift 1.226323]\n",
      "Epoch 2 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:22:20.199138] [Epoch   2;   0] [Time 0.502] [Data 0.158] [LR 0.19000]\n",
      "[LossC 0.000000] [LossSim 4.359697] [LossShift 0.896302]\n",
      "[2022-04-27 21:22:42.722677] [Epoch   2;  50] [Time 0.452] [Data 0.869] [LR 0.20004]\n",
      "[LossC 0.000000] [LossSim 4.424041] [LossShift 0.848778]\n",
      "[2022-04-27 21:23:05.591518] [Epoch   2; 100] [Time 0.452] [Data 0.867] [LR 0.21009]\n",
      "[LossC 0.000000] [LossSim 4.309733] [LossShift 0.864205]\n",
      "[2022-04-27 21:23:28.092864] [Epoch   2; 150] [Time 0.471] [Data 0.871] [LR 0.22013]\n",
      "[LossC 0.000000] [LossSim 4.339020] [LossShift 0.861768]\n",
      "[2022-04-27 21:23:51.151448] [Epoch   2; 200] [Time 0.471] [Data 0.982] [LR 0.23018]\n",
      "[LossC 0.000000] [LossSim 4.398156] [LossShift 0.844045]\n",
      "[2022-04-27 21:24:13.759556] [Epoch   2; 250] [Time 0.474] [Data 0.873] [LR 0.24022]\n",
      "[LossC 0.000000] [LossSim 4.331997] [LossShift 0.895239]\n",
      "[2022-04-27 21:24:36.498251] [Epoch   2; 300] [Time 0.557] [Data 0.844] [LR 0.25027]\n",
      "[LossC 0.000000] [LossSim 4.314375] [LossShift 0.844688]\n",
      "[2022-04-27 21:24:59.086448] [Epoch   2; 350] [Time 0.448] [Data 0.855] [LR 0.26031]\n",
      "[LossC 0.000000] [LossSim 4.494950] [LossShift 0.842451]\n",
      "[2022-04-27 21:25:22.358179] [Epoch   2; 400] [Time 0.509] [Data 0.884] [LR 0.27036]\n",
      "[LossC 0.000000] [LossSim 4.366556] [LossShift 0.884501]\n",
      "[2022-04-27 21:25:43.075378] [DONE] [Time 0.487] [Data 0.907] [LossC 0.000000] [LossSim 4.395404] [LossShift 0.913691]\n",
      "Epoch 3 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:25:44.090938] [Epoch   3;   0] [Time 0.461] [Data 0.134] [LR 0.28000]\n",
      "[LossC 0.000000] [LossSim 4.363524] [LossShift 0.843010]\n",
      "[2022-04-27 21:26:06.906782] [Epoch   3;  50] [Time 0.489] [Data 0.855] [LR 0.29004]\n",
      "[LossC 0.000000] [LossSim 4.475645] [LossShift 1.142160]\n",
      "[2022-04-27 21:26:30.509720] [Epoch   3; 100] [Time 0.454] [Data 0.893] [LR 0.30009]\n",
      "[LossC 0.000000] [LossSim 4.336016] [LossShift 0.952089]\n",
      "[2022-04-27 21:26:53.002780] [Epoch   3; 150] [Time 0.477] [Data 0.860] [LR 0.31013]\n",
      "[LossC 0.000000] [LossSim 4.475717] [LossShift 0.875115]\n",
      "[2022-04-27 21:27:15.597338] [Epoch   3; 200] [Time 0.471] [Data 0.857] [LR 0.32018]\n",
      "[LossC 0.000000] [LossSim 4.349196] [LossShift 0.872518]\n",
      "[2022-04-27 21:27:38.345896] [Epoch   3; 250] [Time 0.463] [Data 0.877] [LR 0.33022]\n",
      "[LossC 0.000000] [LossSim 4.353239] [LossShift 0.881434]\n",
      "[2022-04-27 21:28:01.311768] [Epoch   3; 300] [Time 0.476] [Data 0.876] [LR 0.34027]\n",
      "[LossC 0.000000] [LossSim 4.418363] [LossShift 0.876285]\n",
      "[2022-04-27 21:28:24.109063] [Epoch   3; 350] [Time 0.529] [Data 0.860] [LR 0.35031]\n",
      "[LossC 0.000000] [LossSim 4.391089] [LossShift 0.891998]\n",
      "[2022-04-27 21:28:46.767573] [Epoch   3; 400] [Time 0.490] [Data 0.923] [LR 0.36036]\n",
      "[LossC 0.000000] [LossSim 4.366334] [LossShift 0.961224]\n",
      "[2022-04-27 21:29:07.659288] [DONE] [Time 0.485] [Data 0.909] [LossC 0.000000] [LossSim 4.379301] [LossShift 0.903935]\n",
      "Epoch 4 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:29:08.649924] [Epoch   4;   0] [Time 0.441] [Data 0.154] [LR 0.37000]\n",
      "[LossC 0.000000] [LossSim 4.468335] [LossShift 0.975977]\n",
      "[2022-04-27 21:29:31.468727] [Epoch   4;  50] [Time 0.459] [Data 0.911] [LR 0.38004]\n",
      "[LossC 0.000000] [LossSim 4.803634] [LossShift 2.258877]\n",
      "[2022-04-27 21:29:53.609175] [Epoch   4; 100] [Time 0.471] [Data 0.855] [LR 0.39009]\n",
      "[LossC 0.000000] [LossSim 4.457827] [LossShift 0.855588]\n",
      "[2022-04-27 21:30:16.236645] [Epoch   4; 150] [Time 0.472] [Data 0.861] [LR 0.40013]\n",
      "[LossC 0.000000] [LossSim 4.359911] [LossShift 0.869267]\n",
      "[2022-04-27 21:30:38.965445] [Epoch   4; 200] [Time 0.457] [Data 0.922] [LR 0.41018]\n",
      "[LossC 0.000000] [LossSim 4.300039] [LossShift 0.853143]\n",
      "[2022-04-27 21:31:01.744464] [Epoch   4; 250] [Time 0.464] [Data 0.847] [LR 0.42022]\n",
      "[LossC 0.000000] [LossSim 4.343868] [LossShift 0.904560]\n",
      "[2022-04-27 21:31:24.138632] [Epoch   4; 300] [Time 0.468] [Data 0.929] [LR 0.43027]\n",
      "[LossC 0.000000] [LossSim 4.440177] [LossShift 1.008291]\n",
      "[2022-04-27 21:31:47.197617] [Epoch   4; 350] [Time 0.459] [Data 0.988] [LR 0.44031]\n",
      "[LossC 0.000000] [LossSim 4.313808] [LossShift 0.843529]\n",
      "[2022-04-27 21:32:10.020673] [Epoch   4; 400] [Time 0.464] [Data 0.915] [LR 0.45036]\n",
      "[LossC 0.000000] [LossSim 4.347077] [LossShift 0.842586]\n",
      "[2022-04-27 21:32:30.667648] [DONE] [Time 0.484] [Data 0.903] [LossC 0.000000] [LossSim 4.378773] [LossShift 0.932685]\n",
      "Epoch 5 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:32:31.676676] [Epoch   5;   0] [Time 0.472] [Data 0.141] [LR 0.46000]\n",
      "[LossC 0.000000] [LossSim 4.296750] [LossShift 0.850581]\n",
      "[2022-04-27 21:32:54.231546] [Epoch   5;  50] [Time 0.531] [Data 0.852] [LR 0.47004]\n",
      "[LossC 0.000000] [LossSim 4.324140] [LossShift 0.856480]\n",
      "[2022-04-27 21:33:16.815921] [Epoch   5; 100] [Time 0.554] [Data 0.887] [LR 0.48009]\n",
      "[LossC 0.000000] [LossSim 4.298337] [LossShift 0.911719]\n",
      "[2022-04-27 21:33:39.742560] [Epoch   5; 150] [Time 0.513] [Data 0.938] [LR 0.49013]\n",
      "[LossC 0.000000] [LossSim 4.311210] [LossShift 0.854077]\n",
      "[2022-04-27 21:34:02.227222] [Epoch   5; 200] [Time 0.544] [Data 0.883] [LR 0.50018]\n",
      "[LossC 0.000000] [LossSim 4.316729] [LossShift 0.873590]\n",
      "[2022-04-27 21:34:25.029707] [Epoch   5; 250] [Time 0.595] [Data 0.907] [LR 0.51022]\n",
      "[LossC 0.000000] [LossSim 4.332903] [LossShift 0.852887]\n",
      "[2022-04-27 21:34:47.734705] [Epoch   5; 300] [Time 0.457] [Data 0.884] [LR 0.52027]\n",
      "[LossC 0.000000] [LossSim 4.326703] [LossShift 0.827790]\n",
      "[2022-04-27 21:35:10.065878] [Epoch   5; 350] [Time 0.480] [Data 0.848] [LR 0.53031]\n",
      "[LossC 0.000000] [LossSim 4.629390] [LossShift 0.972859]\n",
      "[2022-04-27 21:35:32.496680] [Epoch   5; 400] [Time 0.471] [Data 0.945] [LR 0.54036]\n",
      "[LossC 0.000000] [LossSim 4.476654] [LossShift 0.924936]\n",
      "[2022-04-27 21:35:53.353584] [DONE] [Time 0.484] [Data 0.901] [LossC 0.000000] [LossSim 4.361738] [LossShift 0.904301]\n",
      "Epoch 6 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:35:54.394370] [Epoch   6;   0] [Time 0.459] [Data 0.168] [LR 0.55000]\n",
      "[LossC 0.000000] [LossSim 4.356859] [LossShift 0.916392]\n",
      "[2022-04-27 21:36:16.884891] [Epoch   6;  50] [Time 0.461] [Data 0.861] [LR 0.56004]\n",
      "[LossC 0.000000] [LossSim 4.396854] [LossShift 0.942714]\n",
      "[2022-04-27 21:36:39.738454] [Epoch   6; 100] [Time 0.460] [Data 0.898] [LR 0.57009]\n",
      "[LossC 0.000000] [LossSim 4.463193] [LossShift 0.884684]\n",
      "[2022-04-27 21:37:02.620539] [Epoch   6; 150] [Time 0.467] [Data 0.885] [LR 0.58013]\n",
      "[LossC 0.000000] [LossSim 4.373494] [LossShift 0.972907]\n",
      "[2022-04-27 21:37:26.181037] [Epoch   6; 200] [Time 0.469] [Data 0.986] [LR 0.59018]\n",
      "[LossC 0.000000] [LossSim 4.492169] [LossShift 0.874383]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2022-04-27 21:37:48.941984] [Epoch   6; 250] [Time 0.455] [Data 0.864] [LR 0.60022]\n",
      "[LossC 0.000000] [LossSim 4.365623] [LossShift 0.879145]\n",
      "[2022-04-27 21:38:11.891998] [Epoch   6; 300] [Time 0.472] [Data 1.195] [LR 0.61027]\n",
      "[LossC 0.000000] [LossSim 4.348284] [LossShift 1.021375]\n",
      "[2022-04-27 21:38:34.705143] [Epoch   6; 350] [Time 0.536] [Data 0.864] [LR 0.62031]\n",
      "[LossC 0.000000] [LossSim 4.290128] [LossShift 0.857135]\n",
      "[2022-04-27 21:38:57.461264] [Epoch   6; 400] [Time 0.467] [Data 0.956] [LR 0.63036]\n",
      "[LossC 0.000000] [LossSim 4.288968] [LossShift 0.835112]\n",
      "[2022-04-27 21:39:18.226831] [DONE] [Time 0.491] [Data 0.911] [LossC 0.000000] [LossSim 4.369289] [LossShift 0.965370]\n",
      "Epoch 7 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:39:19.197901] [Epoch   7;   0] [Time 0.448] [Data 0.145] [LR 0.64000]\n",
      "[LossC 0.000000] [LossSim 4.337277] [LossShift 0.845977]\n",
      "[2022-04-27 21:39:41.903147] [Epoch   7;  50] [Time 0.516] [Data 0.844] [LR 0.65004]\n",
      "[LossC 0.000000] [LossSim 4.348597] [LossShift 0.887782]\n",
      "[2022-04-27 21:40:04.761686] [Epoch   7; 100] [Time 0.462] [Data 0.904] [LR 0.66009]\n",
      "[LossC 0.000000] [LossSim 4.288217] [LossShift 0.847829]\n",
      "[2022-04-27 21:40:27.497629] [Epoch   7; 150] [Time 0.505] [Data 0.909] [LR 0.67013]\n",
      "[LossC 0.000000] [LossSim 4.574395] [LossShift 0.856589]\n",
      "[2022-04-27 21:40:50.169432] [Epoch   7; 200] [Time 0.503] [Data 0.874] [LR 0.68018]\n",
      "[LossC 0.000000] [LossSim 4.347064] [LossShift 1.008280]\n",
      "[2022-04-27 21:41:13.461267] [Epoch   7; 250] [Time 0.535] [Data 0.876] [LR 0.69022]\n",
      "[LossC 0.000000] [LossSim 4.344507] [LossShift 0.942077]\n",
      "[2022-04-27 21:41:36.295103] [Epoch   7; 300] [Time 0.481] [Data 0.856] [LR 0.70027]\n",
      "[LossC 0.000000] [LossSim 4.309855] [LossShift 0.832647]\n",
      "[2022-04-27 21:41:58.827571] [Epoch   7; 350] [Time 0.464] [Data 0.853] [LR 0.71031]\n",
      "[LossC 0.000000] [LossSim 4.432234] [LossShift 1.124480]\n",
      "[2022-04-27 21:42:21.525643] [Epoch   7; 400] [Time 0.462] [Data 0.971] [LR 0.72036]\n",
      "[LossC 0.000000] [LossSim 4.344445] [LossShift 0.938462]\n",
      "[2022-04-27 21:42:42.184827] [DONE] [Time 0.488] [Data 0.907] [LossC 0.000000] [LossSim 4.358003] [LossShift 0.918527]\n",
      "Epoch 8 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:42:43.188401] [Epoch   8;   0] [Time 0.472] [Data 0.151] [LR 0.73000]\n",
      "[LossC 0.000000] [LossSim 4.423952] [LossShift 0.940491]\n",
      "[2022-04-27 21:43:05.626867] [Epoch   8;  50] [Time 0.609] [Data 0.911] [LR 0.74004]\n",
      "[LossC 0.000000] [LossSim 4.442121] [LossShift 0.870375]\n",
      "[2022-04-27 21:43:28.441870] [Epoch   8; 100] [Time 0.480] [Data 0.858] [LR 0.75009]\n",
      "[LossC 0.000000] [LossSim 4.287797] [LossShift 0.879039]\n",
      "[2022-04-27 21:43:51.203855] [Epoch   8; 150] [Time 0.464] [Data 1.064] [LR 0.76013]\n",
      "[LossC 0.000000] [LossSim 4.277451] [LossShift 0.845034]\n",
      "[2022-04-27 21:44:13.634754] [Epoch   8; 200] [Time 0.568] [Data 0.851] [LR 0.77018]\n",
      "[LossC 0.000000] [LossSim 4.329644] [LossShift 0.961596]\n",
      "[2022-04-27 21:44:36.887687] [Epoch   8; 250] [Time 0.723] [Data 0.942] [LR 0.78022]\n",
      "[LossC 0.000000] [LossSim 4.317680] [LossShift 0.864846]\n",
      "[2022-04-27 21:44:59.265520] [Epoch   8; 300] [Time 0.450] [Data 0.856] [LR 0.79027]\n",
      "[LossC 0.000000] [LossSim 4.362687] [LossShift 0.917989]\n",
      "[2022-04-27 21:45:22.337561] [Epoch   8; 350] [Time 0.480] [Data 0.891] [LR 0.80031]\n",
      "[LossC 0.000000] [LossSim 4.263648] [LossShift 0.859828]\n",
      "[2022-04-27 21:45:45.275990] [Epoch   8; 400] [Time 0.497] [Data 0.868] [LR 0.81036]\n",
      "[LossC 0.000000] [LossSim 4.380607] [LossShift 0.836404]\n",
      "[2022-04-27 21:46:06.499931] [DONE] [Time 0.488] [Data 0.908] [LossC 0.000000] [LossSim 4.348544] [LossShift 0.891716]\n",
      "Epoch 9 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:46:07.537821] [Epoch   9;   0] [Time 0.464] [Data 0.159] [LR 0.82000]\n",
      "[LossC 0.000000] [LossSim 4.373352] [LossShift 0.876816]\n",
      "[2022-04-27 21:46:30.396968] [Epoch   9;  50] [Time 0.455] [Data 0.856] [LR 0.83004]\n",
      "[LossC 0.000000] [LossSim 4.306937] [LossShift 0.909936]\n",
      "[2022-04-27 21:46:53.286257] [Epoch   9; 100] [Time 0.451] [Data 0.855] [LR 0.84009]\n",
      "[LossC 0.000000] [LossSim 4.355694] [LossShift 1.014931]\n",
      "[2022-04-27 21:47:16.173773] [Epoch   9; 150] [Time 0.465] [Data 1.050] [LR 0.85013]\n",
      "[LossC 0.000000] [LossSim 4.293055] [LossShift 0.837927]\n",
      "[2022-04-27 21:47:38.465545] [Epoch   9; 200] [Time 0.465] [Data 0.872] [LR 0.86018]\n",
      "[LossC 0.000000] [LossSim 4.365509] [LossShift 0.908220]\n",
      "[2022-04-27 21:48:01.092709] [Epoch   9; 250] [Time 0.461] [Data 0.937] [LR 0.87022]\n",
      "[LossC 0.000000] [LossSim 4.350402] [LossShift 0.842791]\n",
      "[2022-04-27 21:48:24.019747] [Epoch   9; 300] [Time 0.472] [Data 0.906] [LR 0.88027]\n",
      "[LossC 0.000000] [LossSim 4.499863] [LossShift 1.153011]\n",
      "[2022-04-27 21:48:46.872260] [Epoch   9; 350] [Time 0.477] [Data 0.890] [LR 0.89031]\n",
      "[LossC 0.000000] [LossSim 4.301045] [LossShift 0.840660]\n",
      "[2022-04-27 21:49:09.507846] [Epoch   9; 400] [Time 0.447] [Data 0.851] [LR 0.90036]\n",
      "[LossC 0.000000] [LossSim 4.358407] [LossShift 0.889107]\n",
      "[2022-04-27 21:49:30.079116] [DONE] [Time 0.485] [Data 0.905] [LossC 0.000000] [LossSim 4.353526] [LossShift 0.893255]\n",
      "Epoch 10 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_randpers_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:49:31.077872] [Epoch  10;   0] [Time 0.455] [Data 0.157] [LR 0.91000]\n",
      "[LossC 0.000000] [LossSim 4.342908] [LossShift 0.914479]\n",
      "[2022-04-27 21:49:53.899316] [Epoch  10;  50] [Time 0.466] [Data 0.991] [LR 0.92004]\n",
      "[LossC 0.000000] [LossSim 4.321300] [LossShift 0.815638]\n",
      "[2022-04-27 21:50:16.668189] [Epoch  10; 100] [Time 0.497] [Data 0.877] [LR 0.93009]\n",
      "[LossC 0.000000] [LossSim 4.261489] [LossShift 0.859249]\n",
      "[2022-04-27 21:50:39.620289] [Epoch  10; 150] [Time 0.585] [Data 0.871] [LR 0.94013]\n",
      "[LossC 0.000000] [LossSim 4.288896] [LossShift 0.847932]\n",
      "[2022-04-27 21:51:02.703581] [Epoch  10; 200] [Time 0.472] [Data 0.893] [LR 0.95018]\n",
      "[LossC 0.000000] [LossSim 4.321000] [LossShift 0.911242]\n",
      "[2022-04-27 21:51:25.530056] [Epoch  10; 250] [Time 0.460] [Data 0.888] [LR 0.96022]\n",
      "[LossC 0.000000] [LossSim 4.281656] [LossShift 0.857911]\n",
      "[2022-04-27 21:51:48.577854] [Epoch  10; 300] [Time 0.594] [Data 0.853] [LR 0.97027]\n",
      "[LossC 0.000000] [LossSim 4.266364] [LossShift 0.833280]\n",
      "[2022-04-27 21:52:11.521917] [Epoch  10; 350] [Time 0.470] [Data 0.921] [LR 0.98031]\n",
      "[LossC 0.000000] [LossSim 4.421701] [LossShift 0.852391]\n",
      "[2022-04-27 21:52:34.254971] [Epoch  10; 400] [Time 0.472] [Data 1.054] [LR 0.99036]\n",
      "[LossC 0.000000] [LossSim 4.423033] [LossShift 0.933093]\n",
      "[2022-04-27 21:52:55.124955] [DONE] [Time 0.491] [Data 0.912] [LossC 0.000000] [LossSim 4.332921] [LossShift 0.889218]\n"
     ]
    }
   ],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur_randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# blur_sigma  : 40\n",
    "# randpers    : 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --blur_sigma 40 --distortion_scale 0.8 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur_randpers --epochs 10 --batch_size 8 --resize_factor 0.08 --optimizer sgd --one_class_idx 1 --res 450px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ec34e63",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/feoktistovar67431/.local/lib/python3.6/site-packages/torch/distributed/launch.py:186: FutureWarning: The module torch.distributed.launch is deprecated\n",
      "and will be removed in future. Use torchrun.\n",
      "Note that --use_env is set by default in torchrun.\n",
      "If your script expects `--local_rank` argument to be set, please\n",
      "change it to read from `os.environ['LOCAL_RANK']` instead. See \n",
      "https://pytorch.org/docs/stable/distributed.html#launch-utility for \n",
      "further instructions\n",
      "\n",
      "  FutureWarning,\n",
      "WARNING:torch.distributed.run:\n",
      "*****************************************\n",
      "Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. \n",
      "*****************************************\n",
      "Warning:  using Python fallback for SyncBatchNorm, possibly because apex was installed without --cuda_ext.  The exception raised when attempting to import the cuda backend was:  No module named 'syncbn'\n",
      "Warning:  apex was installed without --cpp_ext.  Falling back to Python flatten and unflatten.\n",
      "Warning:  using Python fallback for SyncBatchNorm, possibly because apex was installed without --cuda_ext.  The exception raised when attempting to import the cuda backend was:  No module named 'syncbn'\n",
      "Warning:  apex was installed without --cpp_ext.  Falling back to Python flatten and unflatten.\n",
      "[2022-04-27 21:53:02.070110] Namespace(K_shift=4, batch_size=8, blur_sigma=40.0, color_distort=0.5, dataset='CNMC', distortion_scale=0.6, epochs=10, error_step=5, image_size=(300, 300, 3), load_path=None, local_rank=0, lr_init=0.1, lr_scheduler='cosine', mode='simclr_CSI', model='resnet18_imagenet', multi_gpu=True, n_classes=2, n_gpus=2, n_superclasses=2, no_strict=False, noise_mean=0, noise_std=0.3, one_class_idx=1, ood_batch_size=100, ood_dataset=[0], ood_layer='simclr', ood_samples=1, ood_score=['norm_mean'], optimizer='sgd', print_score=False, proc_step=None, res='450px', resize_factor=0.08, resize_fix=False, resume_path=None, save_score=False, save_step=10, sharpness_factor=128.0, shift_trans=BlurSharpness(\n",
      "  (gauss): GaussBlur()\n",
      "  (sharp): RandomAdjustSharpness()\n",
      "), shift_trans_type='blur_sharp', sim_lambda=1.0, simclr_dim=128, suffix=None, temperature=0.5, test_batch_size=100, warmup=10, weight_decay=1e-06)\n",
      "[2022-04-27 21:53:02.070601] DistributedDataParallel(\n",
      "  (module): ResNet(\n",
      "    (linear): Linear(in_features=512, out_features=2, bias=True)\n",
      "    (simclr_layer): Sequential(\n",
      "      (0): Linear(in_features=512, out_features=512, bias=True)\n",
      "      (1): ReLU()\n",
      "      (2): Linear(in_features=512, out_features=128, bias=True)\n",
      "    )\n",
      "    (shift_cls_layer): Linear(in_features=512, out_features=4, bias=True)\n",
      "    (joint_distribution_layer): Linear(in_features=512, out_features=8, bias=True)\n",
      "    (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)\n",
      "    (bn1): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "    (relu): ReLU(inplace=True)\n",
      "    (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n",
      "    (layer1): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (layer2): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (downsample): Sequential(\n",
      "          (0): Conv2d(64, 128, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
      "          (1): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        )\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (layer3): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (downsample): Sequential(\n",
      "          (0): Conv2d(128, 256, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
      "          (1): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        )\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (layer4): Sequential(\n",
      "      (0): BasicBlock(\n",
      "        (conv1): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (downsample): Sequential(\n",
      "          (0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
      "          (1): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        )\n",
      "      )\n",
      "      (1): BasicBlock(\n",
      "        (conv1): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn1): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "        (relu): ReLU(inplace=True)\n",
      "        (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
      "        (bn2): SyncBatchNorm(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
      "      )\n",
      "    )\n",
      "    (avgpool): AdaptiveAvgPool2d(output_size=(1, 1))\n",
      "    (normalize): NormalizeLayer()\n",
      "  )\n",
      ")\n",
      "Epoch 1 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "/home/feoktistovar67431/.local/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:154: UserWarning: The epoch parameter in `scheduler.step()` was not necessary and is being deprecated where possible. Please use `scheduler.step()` to step the scheduler. During the deprecation, if epoch is different from None, the closed form is used instead of the new chainable form, where available. Please open an issue if you are unable to replicate your use case: https://github.com/pytorch/pytorch/issues/new/choose.\n",
      "  warnings.warn(EPOCH_DEPRECATION_WARNING, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/feoktistovar67431/.local/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:154: UserWarning: The epoch parameter in `scheduler.step()` was not necessary and is being deprecated where possible. Please use `scheduler.step()` to step the scheduler. During the deprecation, if epoch is different from None, the closed form is used instead of the new chainable form, where available. Please open an issue if you are unable to replicate your use case: https://github.com/pytorch/pytorch/issues/new/choose.\n",
      "  warnings.warn(EPOCH_DEPRECATION_WARNING, UserWarning)\n",
      "[2022-04-27 21:53:04.749961] [Epoch   1;   0] [Time 1.525] [Data 0.149] [LR 0.10000]\n",
      "[LossC 0.000000] [LossSim 4.858340] [LossShift 1.407876]\n",
      "[2022-04-27 21:53:25.624987] [Epoch   1;  50] [Time 0.458] [Data 0.878] [LR 0.11004]\n",
      "[LossC 0.000000] [LossSim 4.845747] [LossShift 1.667100]\n",
      "[2022-04-27 21:53:47.668063] [Epoch   1; 100] [Time 0.474] [Data 0.893] [LR 0.12009]\n",
      "[LossC 0.000000] [LossSim 4.844110] [LossShift 1.436306]\n",
      "[2022-04-27 21:54:10.188214] [Epoch   1; 150] [Time 0.454] [Data 0.867] [LR 0.13013]\n",
      "[LossC 0.000000] [LossSim 4.843646] [LossShift 1.547756]\n",
      "[2022-04-27 21:54:33.381892] [Epoch   1; 200] [Time 0.517] [Data 0.932] [LR 0.14018]\n",
      "[LossC 0.000000] [LossSim 4.738900] [LossShift 1.359678]\n",
      "[2022-04-27 21:54:56.617839] [Epoch   1; 250] [Time 0.469] [Data 1.055] [LR 0.15022]\n",
      "[LossC 0.000000] [LossSim 4.796278] [LossShift 1.271640]\n",
      "[2022-04-27 21:55:19.371901] [Epoch   1; 300] [Time 0.469] [Data 0.898] [LR 0.16027]\n",
      "[LossC 0.000000] [LossSim 4.608876] [LossShift 1.552633]\n",
      "[2022-04-27 21:55:42.571197] [Epoch   1; 350] [Time 0.516] [Data 0.918] [LR 0.17031]\n",
      "[LossC 0.000000] [LossSim 4.842148] [LossShift 1.336090]\n",
      "[2022-04-27 21:56:05.642156] [Epoch   1; 400] [Time 0.523] [Data 0.867] [LR 0.18036]\n",
      "[LossC 0.000000] [LossSim 4.832942] [LossShift 1.156906]\n",
      "[2022-04-27 21:56:26.681201] [DONE] [Time 0.489] [Data 0.909] [LossC 0.000000] [LossSim 4.770748] [LossShift 1.591873]\n",
      "Epoch 2 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:56:27.693232] [Epoch   2;   0] [Time 0.440] [Data 0.148] [LR 0.19000]\n",
      "[LossC 0.000000] [LossSim 4.602440] [LossShift 1.091861]\n",
      "[2022-04-27 21:56:50.382773] [Epoch   2;  50] [Time 0.515] [Data 0.877] [LR 0.20004]\n",
      "[LossC 0.000000] [LossSim 4.600789] [LossShift 1.042183]\n",
      "[2022-04-27 21:57:13.401066] [Epoch   2; 100] [Time 0.472] [Data 0.977] [LR 0.21009]\n",
      "[LossC 0.000000] [LossSim 4.711175] [LossShift 1.322048]\n",
      "[2022-04-27 21:57:36.339250] [Epoch   2; 150] [Time 0.608] [Data 0.852] [LR 0.22013]\n",
      "[LossC 0.000000] [LossSim 4.559575] [LossShift 1.136288]\n",
      "[2022-04-27 21:57:59.495503] [Epoch   2; 200] [Time 0.467] [Data 1.097] [LR 0.23018]\n",
      "[LossC 0.000000] [LossSim 4.471087] [LossShift 1.055894]\n",
      "[2022-04-27 21:58:22.207180] [Epoch   2; 250] [Time 0.498] [Data 0.879] [LR 0.24022]\n",
      "[LossC 0.000000] [LossSim 4.526820] [LossShift 0.970052]\n",
      "[2022-04-27 21:58:45.158632] [Epoch   2; 300] [Time 0.468] [Data 1.074] [LR 0.25027]\n",
      "[LossC 0.000000] [LossSim 4.660821] [LossShift 1.274141]\n",
      "[2022-04-27 21:59:08.291492] [Epoch   2; 350] [Time 0.482] [Data 0.860] [LR 0.26031]\n",
      "[LossC 0.000000] [LossSim 4.487653] [LossShift 0.929607]\n",
      "[2022-04-27 21:59:31.435978] [Epoch   2; 400] [Time 0.469] [Data 1.006] [LR 0.27036]\n",
      "[LossC 0.000000] [LossSim 4.729589] [LossShift 1.065959]\n",
      "[2022-04-27 21:59:52.467171] [DONE] [Time 0.494] [Data 0.915] [LossC 0.000000] [LossSim 4.540043] [LossShift 1.051491]\n",
      "Epoch 3 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 21:59:53.543037] [Epoch   3;   0] [Time 0.515] [Data 0.131] [LR 0.28000]\n",
      "[LossC 0.000000] [LossSim 4.606118] [LossShift 1.089750]\n",
      "[2022-04-27 22:00:16.551717] [Epoch   3;  50] [Time 0.454] [Data 0.864] [LR 0.29004]\n",
      "[LossC 0.000000] [LossSim 4.470480] [LossShift 1.156890]\n",
      "[2022-04-27 22:00:39.247741] [Epoch   3; 100] [Time 0.463] [Data 0.960] [LR 0.30009]\n",
      "[LossC 0.000000] [LossSim 4.465283] [LossShift 1.034453]\n",
      "[2022-04-27 22:01:02.437289] [Epoch   3; 150] [Time 0.485] [Data 0.857] [LR 0.31013]\n",
      "[LossC 0.000000] [LossSim 4.579294] [LossShift 1.223945]\n",
      "[2022-04-27 22:01:25.646166] [Epoch   3; 200] [Time 0.458] [Data 0.864] [LR 0.32018]\n",
      "[LossC 0.000000] [LossSim 4.475991] [LossShift 0.937372]\n",
      "[2022-04-27 22:01:48.449946] [Epoch   3; 250] [Time 0.472] [Data 0.846] [LR 0.33022]\n",
      "[LossC 0.000000] [LossSim 4.492799] [LossShift 1.123910]\n",
      "[2022-04-27 22:02:11.088044] [Epoch   3; 300] [Time 0.584] [Data 0.884] [LR 0.34027]\n",
      "[LossC 0.000000] [LossSim 4.520730] [LossShift 1.016755]\n",
      "[2022-04-27 22:02:34.026722] [Epoch   3; 350] [Time 0.462] [Data 0.904] [LR 0.35031]\n",
      "[LossC 0.000000] [LossSim 4.588828] [LossShift 1.008489]\n",
      "[2022-04-27 22:02:57.093785] [Epoch   3; 400] [Time 0.468] [Data 1.008] [LR 0.36036]\n",
      "[LossC 0.000000] [LossSim 4.431605] [LossShift 0.948913]\n",
      "[2022-04-27 22:03:18.112107] [DONE] [Time 0.493] [Data 0.914] [LossC 0.000000] [LossSim 4.458634] [LossShift 1.007948]\n",
      "Epoch 4 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 22:03:19.173064] [Epoch   4;   0] [Time 0.486] [Data 0.144] [LR 0.37000]\n",
      "[LossC 0.000000] [LossSim 4.522823] [LossShift 0.872640]\n",
      "[2022-04-27 22:03:41.681406] [Epoch   4;  50] [Time 0.515] [Data 0.965] [LR 0.38004]\n",
      "[LossC 0.000000] [LossSim 4.627268] [LossShift 1.079998]\n",
      "[2022-04-27 22:04:04.353249] [Epoch   4; 100] [Time 0.456] [Data 0.890] [LR 0.39009]\n",
      "[LossC 0.000000] [LossSim 4.401687] [LossShift 1.002750]\n",
      "[2022-04-27 22:04:27.711134] [Epoch   4; 150] [Time 0.474] [Data 0.937] [LR 0.40013]\n",
      "[LossC 0.000000] [LossSim 4.423962] [LossShift 0.875453]\n",
      "[2022-04-27 22:04:50.564132] [Epoch   4; 200] [Time 0.535] [Data 0.917] [LR 0.41018]\n",
      "[LossC 0.000000] [LossSim 4.401275] [LossShift 0.953443]\n",
      "[2022-04-27 22:05:13.697441] [Epoch   4; 250] [Time 0.459] [Data 0.858] [LR 0.42022]\n",
      "[LossC 0.000000] [LossSim 4.430320] [LossShift 0.948798]\n",
      "[2022-04-27 22:05:36.625607] [Epoch   4; 300] [Time 0.475] [Data 0.875] [LR 0.43027]\n",
      "[LossC 0.000000] [LossSim 4.321131] [LossShift 0.913674]\n",
      "[2022-04-27 22:05:59.610157] [Epoch   4; 350] [Time 0.462] [Data 0.924] [LR 0.44031]\n",
      "[LossC 0.000000] [LossSim 4.468315] [LossShift 0.879398]\n",
      "[2022-04-27 22:06:22.584148] [Epoch   4; 400] [Time 0.462] [Data 0.924] [LR 0.45036]\n",
      "[LossC 0.000000] [LossSim 4.320601] [LossShift 0.835482]\n",
      "[2022-04-27 22:06:43.326378] [DONE] [Time 0.492] [Data 0.912] [LossC 0.000000] [LossSim 4.410098] [LossShift 0.938872]\n",
      "Epoch 5 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 22:06:44.342767] [Epoch   5;   0] [Time 0.473] [Data 0.149] [LR 0.46000]\n",
      "[LossC 0.000000] [LossSim 4.376451] [LossShift 0.939952]\n",
      "[2022-04-27 22:07:06.782078] [Epoch   5;  50] [Time 0.449] [Data 0.856] [LR 0.47004]\n",
      "[LossC 0.000000] [LossSim 4.396927] [LossShift 0.920150]\n",
      "[2022-04-27 22:07:29.728200] [Epoch   5; 100] [Time 0.463] [Data 0.908] [LR 0.48009]\n",
      "[LossC 0.000000] [LossSim 4.447166] [LossShift 0.918573]\n",
      "[2022-04-27 22:07:52.322851] [Epoch   5; 150] [Time 0.473] [Data 1.023] [LR 0.49013]\n",
      "[LossC 0.000000] [LossSim 4.367201] [LossShift 0.944386]\n",
      "[2022-04-27 22:08:15.084181] [Epoch   5; 200] [Time 0.466] [Data 0.909] [LR 0.50018]\n",
      "[LossC 0.000000] [LossSim 4.325580] [LossShift 0.883697]\n",
      "[2022-04-27 22:08:37.787865] [Epoch   5; 250] [Time 0.521] [Data 0.937] [LR 0.51022]\n",
      "[LossC 0.000000] [LossSim 4.426981] [LossShift 0.855859]\n",
      "[2022-04-27 22:09:00.704213] [Epoch   5; 300] [Time 0.467] [Data 0.885] [LR 0.52027]\n",
      "[LossC 0.000000] [LossSim 4.355620] [LossShift 0.837514]\n",
      "[2022-04-27 22:09:23.448209] [Epoch   5; 350] [Time 0.482] [Data 0.899] [LR 0.53031]\n",
      "[LossC 0.000000] [LossSim 4.432379] [LossShift 0.906252]\n",
      "[2022-04-27 22:09:46.070029] [Epoch   5; 400] [Time 0.542] [Data 0.907] [LR 0.54036]\n",
      "[LossC 0.000000] [LossSim 4.362264] [LossShift 0.886713]\n",
      "[2022-04-27 22:10:06.772650] [DONE] [Time 0.486] [Data 0.904] [LossC 0.000000] [LossSim 4.392308] [LossShift 0.915971]\n",
      "Epoch 6 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 22:10:07.752875] [Epoch   6;   0] [Time 0.446] [Data 0.148] [LR 0.55000]\n",
      "[LossC 0.000000] [LossSim 4.358101] [LossShift 0.934794]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2022-04-27 22:10:30.582189] [Epoch   6;  50] [Time 0.484] [Data 0.911] [LR 0.56004]\n",
      "[LossC 0.000000] [LossSim 4.426515] [LossShift 0.982254]\n",
      "[2022-04-27 22:10:53.219031] [Epoch   6; 100] [Time 0.596] [Data 0.861] [LR 0.57009]\n",
      "[LossC 0.000000] [LossSim 4.355786] [LossShift 0.859021]\n",
      "[2022-04-27 22:11:16.124596] [Epoch   6; 150] [Time 0.591] [Data 0.880] [LR 0.58013]\n",
      "[LossC 0.000000] [LossSim 4.331424] [LossShift 0.872154]\n",
      "[2022-04-27 22:11:38.965621] [Epoch   6; 200] [Time 0.449] [Data 0.886] [LR 0.59018]\n",
      "[LossC 0.000000] [LossSim 4.351139] [LossShift 0.876345]\n",
      "[2022-04-27 22:12:01.754661] [Epoch   6; 250] [Time 0.461] [Data 0.920] [LR 0.60022]\n",
      "[LossC 0.000000] [LossSim 4.491778] [LossShift 1.031505]\n",
      "[2022-04-27 22:12:24.410563] [Epoch   6; 300] [Time 0.467] [Data 0.890] [LR 0.61027]\n",
      "[LossC 0.000000] [LossSim 4.340865] [LossShift 0.851271]\n",
      "[2022-04-27 22:12:47.216964] [Epoch   6; 350] [Time 0.467] [Data 0.897] [LR 0.62031]\n",
      "[LossC 0.000000] [LossSim 4.372048] [LossShift 0.921748]\n",
      "[2022-04-27 22:13:09.822383] [Epoch   6; 400] [Time 0.469] [Data 0.935] [LR 0.63036]\n",
      "[LossC 0.000000] [LossSim 4.349135] [LossShift 0.854723]\n",
      "[2022-04-27 22:13:30.781444] [DONE] [Time 0.487] [Data 0.907] [LossC 0.000000] [LossSim 4.368142] [LossShift 0.896633]\n",
      "Epoch 7 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 22:13:31.766230] [Epoch   7;   0] [Time 0.455] [Data 0.133] [LR 0.64000]\n",
      "[LossC 0.000000] [LossSim 4.423601] [LossShift 0.868863]\n",
      "[2022-04-27 22:13:54.496806] [Epoch   7;  50] [Time 0.463] [Data 0.904] [LR 0.65004]\n",
      "[LossC 0.000000] [LossSim 4.383883] [LossShift 0.905446]\n",
      "[2022-04-27 22:14:17.511831] [Epoch   7; 100] [Time 0.470] [Data 1.031] [LR 0.66009]\n",
      "[LossC 0.000000] [LossSim 4.296111] [LossShift 0.895986]\n",
      "[2022-04-27 22:14:40.280189] [Epoch   7; 150] [Time 0.477] [Data 0.871] [LR 0.67013]\n",
      "[LossC 0.000000] [LossSim 4.305459] [LossShift 0.909102]\n",
      "[2022-04-27 22:15:03.937648] [Epoch   7; 200] [Time 0.513] [Data 1.929] [LR 0.68018]\n",
      "[LossC 0.000000] [LossSim 4.345171] [LossShift 0.866567]\n",
      "[2022-04-27 22:15:26.668402] [Epoch   7; 250] [Time 0.594] [Data 0.859] [LR 0.69022]\n",
      "[LossC 0.000000] [LossSim 4.381218] [LossShift 0.895947]\n",
      "[2022-04-27 22:15:49.487447] [Epoch   7; 300] [Time 0.473] [Data 0.861] [LR 0.70027]\n",
      "[LossC 0.000000] [LossSim 4.351787] [LossShift 0.836976]\n",
      "[2022-04-27 22:16:12.051757] [Epoch   7; 350] [Time 0.466] [Data 1.045] [LR 0.71031]\n",
      "[LossC 0.000000] [LossSim 4.400456] [LossShift 0.845599]\n",
      "[2022-04-27 22:16:34.818097] [Epoch   7; 400] [Time 0.468] [Data 0.849] [LR 0.72036]\n",
      "[LossC 0.000000] [LossSim 4.433661] [LossShift 1.035500]\n",
      "[2022-04-27 22:16:56.032426] [DONE] [Time 0.491] [Data 0.912] [LossC 0.000000] [LossSim 4.370436] [LossShift 0.907309]\n",
      "Epoch 8 (logs/CNMC_resnet18_imagenet_unsup_simclr_CSI_450px_shift_blur_sharp_resize_factor0.08_color_dist0.5_one_class_1)\n",
      "[2022-04-27 22:16:57.048328] [Epoch   8;   0] [Time 0.470] [Data 0.160] [LR 0.73000]\n",
      "[LossC 0.000000] [LossSim 4.345762] [LossShift 0.854992]\n"
     ]
    }
   ],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur_sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 128\n",
    "# blur_sigma  : 40\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --blur_sigma 40 --sharpness_factor 128 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur_sharp --epochs 10 --batch_size 8 --resize_factor 0.08 --optimizer sgd --one_class_idx 1 --res 450px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb3bca71",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers_sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 128\n",
    "# randpers    : 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 128 --distortion_scale 0.8 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers_sharp --epochs 10 --batch_size 8 --resize_factor 0.08 --optimizer sgd --one_class_idx 1 --res 450px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "baf0eff6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur_randpers_sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 128\n",
    "# blur_sigma  : 40\n",
    "# randpers    : 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --blur_sigma 40 --sharpness_factor 128 --distortion_scale 0.8 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur_randpers_sharp --epochs 10 --batch_size 8 --resize_factor 0.08 --optimizer sgd --one_class_idx 1 --res 450px"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "30642f7c",
   "metadata": {},
   "source": [
    "# Rotation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d3be9f07",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : rotation\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type rotation --epochs 10 --batch_size 8 --resize_factor 0.08 --optimizer sgd --one_class_idx 1 --res 450px"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d5b3adfc",
   "metadata": {},
   "source": [
    "# Cutperm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2a006f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : rotation\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type cutperm --epochs 10 --batch_size 8 --resize_factor 0.08 --optimizer sgd --one_class_idx 1 --res 450px"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dff09fe7",
   "metadata": {},
   "source": [
    "# Adjust Sharpness"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "695ed30c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 4096\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 4096 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 10 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3537b825",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 2048\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 2048 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a6495274",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 1024\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 1024 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3f9a0fe8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 512\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 512 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "44688e2b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 256\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 256 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e97c21fe",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 150\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 150 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9ecf758b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 140\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 140 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d9767a5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 130\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 130 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bd662097",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 128\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 128 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a7c01b6f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 120\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 120 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d129e42",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 100\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 100 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d70d2983",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 80\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 80 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b32d416",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 64\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 64 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cf996327",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 32\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 32 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d841ffb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 16\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 16 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd929ab1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 8 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e1d33ea1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 5 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0c1fd73c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 4\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 4 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9395e2f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 3\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 3 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "959cc49f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : sharp\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# sharp       : 2\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --sharpness_factor 2 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type sharp --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76fd693e",
   "metadata": {},
   "source": [
    "# Random Perspective"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c6dfe547",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : all\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# randper_dist: 0.95\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --distortion_scale 0.95 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers --epochs 10 --batch_size 8 --optimizer sgd --one_class_idx 0 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ccc4b932",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# randper_dist: 0.9\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --distortion_scale 0.9 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4148f1e6",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# randper_dist: 0.85\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --distortion_scale 0.85 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "022d5ce0",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# randper_dist: 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --distortion_scale 0.8 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2bec00e6",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# randper_dist: 0.75\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --distortion_scale 0.75 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1875267e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# randper_dist: 0.6\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --distortion_scale 0.6 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a02ed7ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : randpers\n",
    "# crop        : 0.08\n",
    "# color_dist  : 0.5\n",
    "# randper_dist: 0.3\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --distortion_scale 0.3 --resize_factor 0.08 --res 450px --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type randpers --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d599ef3f",
   "metadata": {},
   "source": [
    "## Examine crop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7195ad51",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : all\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.5\n",
    "# blur_sigma  : 2\n",
    "# color_dist  : 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.5 --res 450px --blur_sigma 2 --color_distort 0.8 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 10 --batch_size 8 --optimizer sgd --one_class_idx 0 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7401d0e7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : all\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.3\n",
    "# blur_sigma  : 2\n",
    "# color_dist  : 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.3 --res 450px --blur_sigma 2 --color_distort 0.8 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 0 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b88a2670",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : all\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.02\n",
    "# blur_sigma  : 2\n",
    "# color_dist  : 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.02 --res 450px --blur_sigma 2 --color_distort 0.8 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 0 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "83922b52",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : all\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.008\n",
    "# blur_sigma  : 2\n",
    "# color_dist  : 0.8\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.008 --res 450px --blur_sigma 2 --color_distort 0.8 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 0 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "006079f3",
   "metadata": {},
   "source": [
    "## Examine blur_sigma"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b65d654",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 180\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 180 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 10 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8aa50f84",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 120\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 120 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f94522c3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 110\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 110 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8bd4c63a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 105\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 105 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cade09f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 100\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 100 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0f1af3f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 95\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 95 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e5b5e043",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 90\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 90 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f4c30628",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 80\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --gauss_sigma 80 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13a022fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 60\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 60 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "02779f69",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 40\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 40 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b63a705a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 20\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 20 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dde3e377",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 6\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 6 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c23c0e0a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 4\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 4 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35fbd79f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 3\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 3 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "42510921",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 2\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 2 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7672da24",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 1.5\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 1.5 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1e94687e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TRAINING\n",
    "# dataset     : CNMC\n",
    "# res         : 450px\n",
    "# id_class    : hem\n",
    "# epoch       : 100\n",
    "# shift_tr    : blur\n",
    "# crop        : 0.08\n",
    "# blur_sigma  : 1\n",
    "# color_dist  : 0.5\n",
    "!CUDA_VISIBLE_DEVICES=0,1 python3 -m torch.distributed.launch --nproc_per_node=2 \"train.py\" --resize_factor 0.08 --res 450px --blur_sigma 1 --color_distort 0.5 --dataset 'CNMC' --model 'resnet18_imagenet' --mode simclr_CSI --shift_trans_type blur --epochs 100 --batch_size 8 --optimizer sgd --one_class_idx 1 "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
