{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from tqdm import tqdm\n",
    "import os\n",
    "from pytorch_adapt.containers import Models, Optimizers\n",
    "from pytorch_adapt.datasets import DataloaderCreator, get_mnist_mnistm, get_office31\n",
    "from pytorch_adapt.datasets.office31 import Office31\n",
    "from pytorch_adapt.hooks import DANNHook\n",
    "from pytorch_adapt.adapters import DANN\n",
    "\n",
    "from pytorch_adapt.models import Discriminator, mnistC, mnistG, office31C, office31G\n",
    "from pytorch_adapt.utils.common_functions import batch_to_device\n",
    "from pytorch_adapt.validators import IMValidator, AccuracyValidator\n",
    "\n",
    "from pprint import pprint\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "root=\"datasets/pytorch-adapt/\"\n",
    "batch_size=32\n",
    "num_workers=2\n",
    "\n",
    "datasets = get_office31([\"amazon\"], [\"webcam\"], folder=root, return_target_with_labels=True)\n",
    "dc = DataloaderCreator(batch_size=batch_size, \n",
    "                        num_workers=num_workers, \n",
    "                        train_names=[\"train\"],\n",
    "                        val_names=[\"src_train\", \"target_train\", \"src_val\", \"target_val\", \"target_train_with_labels\", \"target_val_with_labels\"])\n",
    "dataloaders = dc(**datasets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys(['src_train', 'src_val', 'target_train', 'target_val', 'target_train_with_labels', 'target_val_with_labels', 'train'])\n"
     ]
    }
   ],
   "source": [
    "print(dataloaders.keys())\n",
    "# 'train' dataset type is `CombinedSourceAndTargetDataset` and contains both source and unlabeled target data\n",
    "# 'src_train' and 'src_val' datasets types are `SourceDataset`\n",
    "# Other datasets are typed `TargetDataset`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "src_train 71 2253\n",
      "dict_keys(['src_imgs', 'src_domain', 'src_labels', 'src_sample_idx'])\n",
      "src_val 18 564\n",
      "dict_keys(['src_imgs', 'src_domain', 'src_labels', 'src_sample_idx'])\n",
      "target_train 20 636\n",
      "dict_keys(['target_imgs', 'target_domain', 'target_sample_idx'])\n",
      "target_val 5 159\n",
      "dict_keys(['target_imgs', 'target_domain', 'target_sample_idx'])\n",
      "target_train_with_labels 20 636\n",
      "dict_keys(['target_imgs', 'target_domain', 'target_sample_idx', 'target_labels'])\n",
      "target_val_with_labels 5 159\n",
      "dict_keys(['target_imgs', 'target_domain', 'target_sample_idx', 'target_labels'])\n",
      "train 19 636\n",
      "dict_keys(['src_imgs', 'src_domain', 'src_labels', 'src_sample_idx', 'target_imgs', 'target_domain', 'target_sample_idx'])\n"
     ]
    }
   ],
   "source": [
    "for k in dataloaders.keys():\n",
    "    print(k, len(dataloaders[k]), len(dataloaders[k].dataset))\n",
    "    for a in dataloaders[k]:\n",
    "        print(a.keys())\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "device = torch.device(\"cuda\")\n",
    "weights_root = os.path.join(root, \"weights\")\n",
    "trained_domain = \"amazon\"\n",
    "\n",
    "G = office31G(pretrained=True, model_dir=weights_root).to(device)\n",
    "C = office31C(domain=trained_domain, pretrained=True, model_dir=weights_root).to(device)\n",
    "D = Discriminator(in_size=2048, h=256).to(device)\n",
    "models = Models({\"G\": G, \"C\": C, \"D\": D})\n",
    "optimizers = Optimizers((torch.optim.Adam, {\"lr\": 0.001}))\n",
    "optimizers.create_with(models)\n",
    "optimizers = list(optimizers.values())\n",
    "\n",
    "hook = DANNHook(optimizers)\n",
    "\n",
    "from pytorch_adapt.validators import AccuracyValidator, BaseValidator\n",
    "from pytorch_adapt.layers import BNMLoss\n",
    "\n",
    "class CustomTargetValidator(BaseValidator):\n",
    "    def compute_score(self, target_train):\n",
    "        return BNMLoss()(target_train[\"preds\"])\n",
    "\n",
    "src_train_validator = AccuracyValidator(key_map={\"src_train\": \"src_val\"})\n",
    "src_val_validator = AccuracyValidator(key_map={\"src_val\": \"src_val\"})\n",
    "target_validator = CustomTargetValidator()\n",
    "target_train_oracle_validator = AccuracyValidator(key_map={\"target_train\": \"src_val\"})\n",
    "target_val_oracle_validator = AccuracyValidator(key_map={\"target_val\": \"src_val\"})\n",
    "targen_im_validator = IMValidator()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 19/19 [00:49<00:00,  2.63s/it]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'total_loss': {'src_c_loss': 3.168257236480713,\n",
      "                'src_domain_loss': 0.7317013740539551,\n",
      "                'target_domain_loss': 0.6301205158233643,\n",
      "                'total': 1.5100263357162476}}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:08<00:00,  2.03it/s]\n",
      "100%|██████████| 5/5 [00:02<00:00,  1.69it/s]\n",
      "100%|██████████| 20/20 [00:09<00:00,  2.16it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Target Evaluation:\n",
      "src_val accuracy \t= 0.12411347776651382\n",
      "target_train accuracy \t= 0.08805031329393387\n",
      "target_train score (IM) \t= 0.4806191921234131\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 19/19 [00:51<00:00,  2.69s/it]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'total_loss': {'src_c_loss': 2.804849624633789,\n",
      "                'src_domain_loss': 0.6947869062423706,\n",
      "                'target_domain_loss': 0.6891149282455444,\n",
      "                'total': 1.3962504863739014}}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:08<00:00,  2.02it/s]\n",
      "100%|██████████| 5/5 [00:02<00:00,  1.68it/s]\n",
      "100%|██████████| 20/20 [00:09<00:00,  2.15it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Target Evaluation:\n",
      "src_val accuracy \t= 0.13652482628822327\n",
      "target_train accuracy \t= 0.16352201998233795\n",
      "target_train score (IM) \t= 0.6105575561523438\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 19/19 [00:51<00:00,  2.71s/it]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'total_loss': {'src_c_loss': 3.0151782035827637,\n",
      "                'src_domain_loss': 0.7150613069534302,\n",
      "                'target_domain_loss': 0.8466196060180664,\n",
      "                'total': 1.5256197452545166}}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:08<00:00,  2.03it/s]\n",
      "100%|██████████| 5/5 [00:02<00:00,  1.68it/s]\n",
      "100%|██████████| 20/20 [00:09<00:00,  2.14it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Target Evaluation:\n",
      "src_val accuracy \t= 0.14007091522216797\n",
      "target_train accuracy \t= 0.1949685513973236\n",
      "target_train score (IM) \t= 1.0187971591949463\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 19/19 [00:52<00:00,  2.75s/it]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'total_loss': {'src_c_loss': 2.8740577697753906,\n",
      "                'src_domain_loss': 0.6584925651550293,\n",
      "                'target_domain_loss': 0.7099870443344116,\n",
      "                'total': 1.4141792058944702}}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 18/18 [00:08<00:00,  2.17it/s]\n",
      "100%|██████████| 5/5 [00:02<00:00,  1.73it/s]\n",
      "100%|██████████| 20/20 [00:09<00:00,  2.15it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Target Evaluation:\n",
      "src_val accuracy \t= 0.13297872245311737\n",
      "target_train accuracy \t= 0.23270440101623535\n",
      "target_train score (IM) \t= 0.8761472702026367\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 89%|████████▉ | 17/19 [00:48<00:05,  2.82s/it]\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[4], line 29\u001b[0m\n\u001b[1;32m     27\u001b[0m \u001b[39mfor\u001b[39;00m data \u001b[39min\u001b[39;00m tqdm(dataloaders[\u001b[39m\"\u001b[39m\u001b[39mtrain\u001b[39m\u001b[39m\"\u001b[39m]):\n\u001b[1;32m     28\u001b[0m     data \u001b[39m=\u001b[39m batch_to_device(data, device)\n\u001b[0;32m---> 29\u001b[0m     _, loss \u001b[39m=\u001b[39m hook({\u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mmodels, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mdata})\n\u001b[1;32m     30\u001b[0m pprint(loss)\n\u001b[1;32m     32\u001b[0m \u001b[39m# eval loop\u001b[39;00m\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:194\u001b[0m, in \u001b[0;36mBaseWrapperHook.call\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m    192\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcall\u001b[39m(\u001b[39mself\u001b[39m, \u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[1;32m    193\u001b[0m     \u001b[39m\"\"\"\"\"\"\u001b[39;00m\n\u001b[0;32m--> 194\u001b[0m     \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mhook(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/utils.py:109\u001b[0m, in \u001b[0;36mChainHook.call\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m    107\u001b[0m all_losses \u001b[39m=\u001b[39m {\u001b[39m*\u001b[39m\u001b[39m*\u001b[39mall_losses, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mprev_losses}\n\u001b[1;32m    108\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mconditions[i](all_inputs, all_losses):\n\u001b[0;32m--> 109\u001b[0m     x \u001b[39m=\u001b[39m h(all_inputs, all_losses)\n\u001b[1;32m    110\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m    111\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39malts[i](all_inputs, all_losses)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/optimizer.py:51\u001b[0m, in \u001b[0;36mOptimizerHook.call\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     49\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcall\u001b[39m(\u001b[39mself\u001b[39m, inputs, losses):\n\u001b[1;32m     50\u001b[0m     \u001b[39m\"\"\"\"\"\"\u001b[39;00m\n\u001b[0;32m---> 51\u001b[0m     outputs, losses \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mhook(inputs, losses)\n\u001b[1;32m     52\u001b[0m     combined \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39massert_dicts_are_disjoint(inputs, outputs)\n\u001b[1;32m     53\u001b[0m     new_outputs, losses \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mreducer(combined, losses)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/utils.py:109\u001b[0m, in \u001b[0;36mChainHook.call\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m    107\u001b[0m all_losses \u001b[39m=\u001b[39m {\u001b[39m*\u001b[39m\u001b[39m*\u001b[39mall_losses, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mprev_losses}\n\u001b[1;32m    108\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mconditions[i](all_inputs, all_losses):\n\u001b[0;32m--> 109\u001b[0m     x \u001b[39m=\u001b[39m h(all_inputs, all_losses)\n\u001b[1;32m    110\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m    111\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39malts[i](all_inputs, all_losses)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/utils.py:318\u001b[0m, in \u001b[0;36mAssertHook.call\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m    316\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcall\u001b[39m(\u001b[39mself\u001b[39m, inputs, losses):\n\u001b[1;32m    317\u001b[0m     \u001b[39m\"\"\"\"\"\"\u001b[39;00m\n\u001b[0;32m--> 318\u001b[0m     outputs, losses \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mhook(inputs, losses)\n\u001b[1;32m    319\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39massert_fn(outputs)\n\u001b[1;32m    320\u001b[0m     \u001b[39mreturn\u001b[39;00m outputs, losses\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/utils.py:220\u001b[0m, in \u001b[0;36mOnlyNewOutputsHook.call\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m    218\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcall\u001b[39m(\u001b[39mself\u001b[39m, inputs, losses):\n\u001b[1;32m    219\u001b[0m     \u001b[39m\"\"\"\"\"\"\u001b[39;00m\n\u001b[0;32m--> 220\u001b[0m     outputs, losses \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mhook(inputs, losses)\n\u001b[1;32m    221\u001b[0m     outputs \u001b[39m=\u001b[39m {k: outputs[k] \u001b[39mfor\u001b[39;00m k \u001b[39min\u001b[39;00m (outputs\u001b[39m.\u001b[39mkeys() \u001b[39m-\u001b[39m inputs\u001b[39m.\u001b[39mkeys())}\n\u001b[1;32m    222\u001b[0m     c_f\u001b[39m.\u001b[39massert_dicts_are_disjoint(inputs, outputs)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/utils.py:109\u001b[0m, in \u001b[0;36mChainHook.call\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m    107\u001b[0m all_losses \u001b[39m=\u001b[39m {\u001b[39m*\u001b[39m\u001b[39m*\u001b[39mall_losses, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mprev_losses}\n\u001b[1;32m    108\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mconditions[i](all_inputs, all_losses):\n\u001b[0;32m--> 109\u001b[0m     x \u001b[39m=\u001b[39m h(all_inputs, all_losses)\n\u001b[1;32m    110\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m    111\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39malts[i](all_inputs, all_losses)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/base.py:52\u001b[0m, in \u001b[0;36mBaseHook.__call__\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m     51\u001b[0m     inputs \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mmap_keys(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkey_map)\n\u001b[0;32m---> 52\u001b[0m     x \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcall(inputs, losses)\n\u001b[1;32m     53\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(x, (\u001b[39mbool\u001b[39m, np\u001b[39m.\u001b[39mbool_)):\n\u001b[1;32m     54\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39mreset()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/utils.py:249\u001b[0m, in \u001b[0;36mApplyFnHook.call\u001b[0;34m(self, inputs, losses)\u001b[0m\n\u001b[1;32m    247\u001b[0m \u001b[39m\"\"\"\"\"\"\u001b[39;00m\n\u001b[1;32m    248\u001b[0m x \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mextract(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mapply_to)\n\u001b[0;32m--> 249\u001b[0m outputs \u001b[39m=\u001b[39m {k: \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mfn(v) \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m \u001b[39mzip\u001b[39m(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mapply_to, x)}\n\u001b[1;32m    250\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mis_loss:\n\u001b[1;32m    251\u001b[0m     \u001b[39mreturn\u001b[39;00m outputs, {}\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/hooks/utils.py:249\u001b[0m, in \u001b[0;36m<dictcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m    247\u001b[0m \u001b[39m\"\"\"\"\"\"\u001b[39;00m\n\u001b[1;32m    248\u001b[0m x \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mextract(inputs, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mapply_to)\n\u001b[0;32m--> 249\u001b[0m outputs \u001b[39m=\u001b[39m {k: \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mfn(v) \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m \u001b[39mzip\u001b[39m(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mapply_to, x)}\n\u001b[1;32m    250\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mis_loss:\n\u001b[1;32m    251\u001b[0m     \u001b[39mreturn\u001b[39;00m outputs, {}\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/modules/module.py:889\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m    887\u001b[0m     result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_slow_forward(\u001b[39m*\u001b[39m\u001b[39minput\u001b[39m, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[1;32m    888\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 889\u001b[0m     result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mforward(\u001b[39m*\u001b[39;49m\u001b[39minput\u001b[39;49m, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m    890\u001b[0m \u001b[39mfor\u001b[39;00m hook \u001b[39min\u001b[39;00m itertools\u001b[39m.\u001b[39mchain(\n\u001b[1;32m    891\u001b[0m         _global_forward_hooks\u001b[39m.\u001b[39mvalues(),\n\u001b[1;32m    892\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_forward_hooks\u001b[39m.\u001b[39mvalues()):\n\u001b[1;32m    893\u001b[0m     hook_result \u001b[39m=\u001b[39m hook(\u001b[39mself\u001b[39m, \u001b[39minput\u001b[39m, result)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/layers/gradient_reversal.py:31\u001b[0m, in \u001b[0;36mGradientReversal.forward\u001b[0;34m(self, x)\u001b[0m\n\u001b[1;32m     29\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mforward\u001b[39m(\u001b[39mself\u001b[39m, x):\n\u001b[1;32m     30\u001b[0m     \u001b[39m\"\"\"\"\"\"\u001b[39;00m\n\u001b[0;32m---> 31\u001b[0m     \u001b[39mreturn\u001b[39;00m _GradientReversal\u001b[39m.\u001b[39mapply(x, pml_cf\u001b[39m.\u001b[39;49mto_device(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mweight, x))\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_metric_learning/utils/common_functions.py:492\u001b[0m, in \u001b[0;36mto_device\u001b[0;34m(x, tensor, device, dtype)\u001b[0m\n\u001b[1;32m    490\u001b[0m dv \u001b[39m=\u001b[39m device \u001b[39mif\u001b[39;00m device \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39melse\u001b[39;00m tensor\u001b[39m.\u001b[39mdevice\n\u001b[1;32m    491\u001b[0m \u001b[39mif\u001b[39;00m x\u001b[39m.\u001b[39mdevice \u001b[39m!=\u001b[39m dv:\n\u001b[0;32m--> 492\u001b[0m     x \u001b[39m=\u001b[39m x\u001b[39m.\u001b[39;49mto(dv)\n\u001b[1;32m    493\u001b[0m \u001b[39mif\u001b[39;00m dtype \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m    494\u001b[0m     x \u001b[39m=\u001b[39m to_dtype(x, dtype\u001b[39m=\u001b[39mdtype)\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    },
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31mThe Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
     ]
    }
   ],
   "source": [
    "torch.cuda.empty_cache()\n",
    "\n",
    "\n",
    "from tqdm import tqdm\n",
    "from pytorch_adapt.utils.common_functions import batch_to_device\n",
    "from collections import defaultdict\n",
    "\n",
    "\n",
    "def get_preds_and_labels(split, full_key):\n",
    "    output = defaultdict(list)\n",
    "    with torch.no_grad():\n",
    "        for data in tqdm(dataloaders[full_key]):\n",
    "            data = batch_to_device(data, device)\n",
    "            logits = C(G(data[f\"{split}_imgs\"]))\n",
    "            output[\"logits\"].append(logits)\n",
    "            curr_preds = torch.softmax(logits, dim=1)\n",
    "            output[\"preds\"].append(curr_preds)\n",
    "            if full_key in [\"src_train\", \"src_val\", \"target_train_with_labels\", \"target_val_with_labels\"]:\n",
    "                output[\"labels\"].append(data[f\"{split}_labels\"])\n",
    "    for k,v in output.items():\n",
    "        output[k] = torch.cat(v, dim=0)\n",
    "    return output\n",
    "    \n",
    "for epoch in range(100):\n",
    "    # train loop\n",
    "    models.train()\n",
    "    for data in tqdm(dataloaders[\"train\"]):\n",
    "        data = batch_to_device(data, device)\n",
    "        _, loss = hook({**models, **data})\n",
    "    pprint(loss)\n",
    "\n",
    "    # eval loop\n",
    "    scores = []\n",
    "    # src_outputs = get_preds_and_labels(\"src\", \"src_train\")\n",
    "    # score = src_train_validator(src_train=src_outputs)\n",
    "    # scores.append(f\"src_train accuracy \\t= {score}\")\n",
    "\n",
    "    src_outputs = get_preds_and_labels(\"src\", \"src_val\")\n",
    "    score = src_val_validator(src_val=src_outputs)\n",
    "    scores.append(f\"src_val accuracy \\t= {score}\")\n",
    "\n",
    "    # target_outputs = get_preds_and_labels(\"target\", \"target_train_with_labels\")\n",
    "    # score = target_train_oracle_validator(target_train=target_outputs)\n",
    "    # scores.append(f\"target_train accuracy \\t= {score}\")\n",
    "\n",
    "    target_outputs = get_preds_and_labels(\"target\", \"target_val_with_labels\")\n",
    "    score = target_val_oracle_validator(target_val=target_outputs)\n",
    "    scores.append(f\"target_train accuracy \\t= {score}\")\n",
    "\n",
    "    target_outputs = get_preds_and_labels(\"target\", \"target_train\")\n",
    "    score = targen_im_validator(target_train={\"logits\": target_outputs['logits']})\n",
    "    scores.append(f\"target_train score (IM)\\t= {score}\")\n",
    "\n",
    "    # score = target_validator(target_train=target_outputs)\n",
    "    # scores.append(f\"target_train score (BNM) \\t= {score}\")\n",
    "\n",
    "    print(f\"Target Evaluation:\")\n",
    "    print(*scores, sep=\"\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "torch.cuda.empty_cache()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Dataset Visualization"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['amazon']\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 135144 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['dslr']\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 239588 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['webcam']\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 257932 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import torchvision\n",
    "\n",
    "mean = [0.485, 0.456, 0.406]\n",
    "std = [0.229, 0.224, 0.225]\n",
    "\n",
    "inv_normalize = torchvision.transforms.Normalize(\n",
    "    mean=[-m / s for m, s in zip(mean, std)], std=[1 / s for s in std]\n",
    ")\n",
    "\n",
    "def imshow(img, figsize=(8, 4)):\n",
    "    img = inv_normalize(img)\n",
    "    npimg = img.numpy()\n",
    "    plt.figure(figsize=figsize)\n",
    "    plt.imshow(np.transpose(npimg, (1, 2, 0)))\n",
    "    plt.show()\n",
    "\n",
    "def imshow_many(datasets, src, target):\n",
    "    d = datasets[\"train\"]\n",
    "    for name in [\"src_imgs\", \"target_imgs\"]:\n",
    "        domains = src if name == \"src_imgs\" else target\n",
    "        if len(domains) == 0:\n",
    "            continue\n",
    "        print(domains)\n",
    "        imgs = [d[i][name] for i in np.random.choice(len(d), size=16, replace=False)]\n",
    "        imshow(torchvision.utils.make_grid(imgs))\n",
    "\n",
    "for src, target in [([\"amazon\"], [\"dslr\"]), ([\"webcam\"], [])]:\n",
    "    datasets = get_office31(src, target,folder=root)\n",
    "    imshow_many(datasets, src, target)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ignite"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import logging\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import torch\n",
    "import umap\n",
    "from tqdm import tqdm\n",
    "import os\n",
    "\n",
    "from pytorch_adapt.adapters import DANN, MCD\n",
    "from pytorch_adapt.containers import Models, Optimizers, LRSchedulers\n",
    "from pytorch_adapt.datasets import DataloaderCreator, get_mnist_mnistm, get_office31\n",
    "from pytorch_adapt.frameworks.ignite import CheckpointFnCreator, Ignite\n",
    "from pytorch_adapt.models import Discriminator, mnistC, mnistG, office31C, office31G\n",
    "from pytorch_adapt.validators import AccuracyValidator, IMValidator, ScoreHistory\n",
    "\n",
    "from pprint import pprint\n",
    "\n",
    "\n",
    "logging.basicConfig()\n",
    "logging.getLogger(\"pytorch-adapt\").setLevel(logging.INFO)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "class VizHook:\n",
    "    def __init__(self):\n",
    "        self.required_data = [\"src_val\", \"target_val\", \"target_val_with_labels\"]\n",
    "\n",
    "    def __call__(self, epoch, src_val, target_val, target_val_with_labels, **kwargs):\n",
    "\n",
    "        accuracy_validator = AccuracyValidator()\n",
    "        accuracy = accuracy_validator.compute_score(src_val=src_val)\n",
    "        print(\"src_val accuracy:\", accuracy)\n",
    "        accuracy_validator = AccuracyValidator()\n",
    "        accuracy = accuracy_validator.compute_score(src_val=target_val_with_labels)\n",
    "        print(\"target_val accuracy:\", accuracy)\n",
    "\n",
    "        if epoch % 1 != 0:\n",
    "            return\n",
    "\n",
    "        features = [src_val[\"features\"], target_val[\"features\"]]\n",
    "        domain = [src_val[\"domain\"], target_val[\"domain\"]]\n",
    "        features = torch.cat(features, dim=0).cpu().numpy()\n",
    "        domain = torch.cat(domain, dim=0).cpu().numpy()\n",
    "        emb = umap.UMAP().fit_transform(features)\n",
    "\n",
    "        df = pd.DataFrame(emb).assign(domain=domain)\n",
    "        df[\"domain\"] = df[\"domain\"].replace({0: \"Source\", 1: \"Target\"})\n",
    "        sns.set_theme(style=\"white\", rc={\"figure.figsize\": (6, 4)})\n",
    "        sns.scatterplot(data=df, x=0, y=1, hue=\"domain\", s=15)\n",
    "        plt.savefig(f\"results/vishook/dann/val_{epoch}.png\") \n",
    "        plt.show()\n",
    "        plt.close('all')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "root=\"datasets/pytorch-adapt/\"\n",
    "batch_size=32\n",
    "num_workers=2\n",
    "\n",
    "datasets = get_office31([\"amazon\"], [\"webcam\"], folder=root, return_target_with_labels=True)\n",
    "dc = DataloaderCreator(batch_size=batch_size, \n",
    "                        num_workers=num_workers, \n",
    "                        train_names=[\"train\"],\n",
    "                        val_names=[\"src_train\", \"target_train\", \"src_val\", \"target_val\", \"target_train_with_labels\", \"target_val_with_labels\"])\n",
    "dataloaders = dc(**datasets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-05-21 13:49:42,518 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n",
      "2021-05-21 13:49:42,519 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n",
      "2021-05-21 13:49:42,520 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n"
     ]
    }
   ],
   "source": [
    "device = torch.device(\"cuda\")\n",
    "weights_root = os.path.join(root, \"weights\")\n",
    "trained_domain = \"amazon\"\n",
    "\n",
    "G = office31G(pretrained=True, model_dir=weights_root).to(device)\n",
    "C = office31C(domain=trained_domain, pretrained=True, model_dir=weights_root).to(device)\n",
    "D = Discriminator(in_size=2048, h=1024).to(device)\n",
    "\n",
    "models = Models({\"G\": G, \"C\": C, \"D\": D})\n",
    "\n",
    "optimizers = Optimizers((torch.optim.Adam, {\"lr\": 0.0005}))\n",
    "lr_schedulers = LRSchedulers((torch.optim.lr_scheduler.ExponentialLR, {\"gamma\": 0.99}))\n",
    "\n",
    "adapter = DANN(models=models, optimizers=optimizers, lr_schedulers=lr_schedulers)\n",
    "checkpoint_fn = CheckpointFnCreator(dirname=\"saved_models\", require_empty=False)\n",
    "validator = ScoreHistory(IMValidator())\n",
    "tarAccuracyValidator = AccuracyValidator(key_map={\"target_val_with_labels\":\"src_val\"})\n",
    "val_hooks = [ScoreHistory(AccuracyValidator()), ScoreHistory(tarAccuracyValidator), VizHook()]\n",
    "trainer = Ignite(\n",
    "    adapter, validator=validator, val_hooks=val_hooks, checkpoint_fn=checkpoint_fn\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-05-21 14:16:07,148 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n",
      "2021-05-21 14:16:07,152 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n"
     ]
    }
   ],
   "source": [
    "from pytorch_adapt.layers import MultipleModels\n",
    "from pytorch_adapt.utils import common_functions \n",
    "import copy\n",
    "\n",
    "device = torch.device(\"cuda\")\n",
    "weights_root = os.path.join(root, \"weights\")\n",
    "trained_domain = \"amazon\"\n",
    "\n",
    "G = office31G(pretrained=True, model_dir=weights_root).to(device)\n",
    "C0 = office31C(domain=trained_domain, pretrained=True, model_dir=weights_root).to(device)\n",
    "C1 = common_functions.reinit(copy.deepcopy(C0))\n",
    "C = MultipleModels(C0, C1)\n",
    "\n",
    "models = Models({\"G\": G, \"C\": C})\n",
    "\n",
    "optimizers = Optimizers((torch.optim.Adam, {\"lr\": 0.0005}))\n",
    "lr_schedulers = LRSchedulers((torch.optim.lr_scheduler.ExponentialLR, {\"gamma\": 0.99}))\n",
    "\n",
    "adapter= MCD(models=models, optimizers=optimizers, lr_schedulers=lr_schedulers)\n",
    "# adapter = DANN(models=models, optimizers=optimizers, lr_schedulers=lr_schedulers)\n",
    "checkpoint_fn = CheckpointFnCreator(dirname=\"saved_models\", require_empty=False)\n",
    "validator = ScoreHistory(IMValidator())\n",
    "tarAccuracyValidator = AccuracyValidator(key_map={\"target_val_with_labels\":\"src_val\"})\n",
    "val_hooks = [ScoreHistory(AccuracyValidator()), ScoreHistory(tarAccuracyValidator), VizHook()]\n",
    "trainer = Ignite(\n",
    "    adapter, validator=validator, val_hooks=val_hooks, checkpoint_fn=checkpoint_fn\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING:pytorch-adapt:val_hook has no state_dict or load_state_dict so it will not be saved or loaded\n"
     ]
    },
    {
     "ename": "RuntimeError",
     "evalue": "CUDA error: out of memory",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mRuntimeError\u001b[0m                              Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[8], line 3\u001b[0m\n\u001b[1;32m      1\u001b[0m logging\u001b[39m.\u001b[39mgetLogger(\u001b[39m\"\u001b[39m\u001b[39mpytorch-adapt\u001b[39m\u001b[39m\"\u001b[39m)\u001b[39m.\u001b[39msetLevel(logging\u001b[39m.\u001b[39mWARNING)\n\u001b[0;32m----> 3\u001b[0m best_score, best_epoch \u001b[39m=\u001b[39m trainer\u001b[39m.\u001b[39;49mrun(\n\u001b[1;32m      4\u001b[0m     datasets, dataloader_creator\u001b[39m=\u001b[39;49mdc, max_epochs\u001b[39m=\u001b[39;49m\u001b[39m5\u001b[39;49m, check_initial_score\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m\n\u001b[1;32m      5\u001b[0m )\n\u001b[1;32m      6\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mbest_score=\u001b[39m\u001b[39m{\u001b[39;00mbest_score\u001b[39m}\u001b[39;00m\u001b[39m, best_epoch=\u001b[39m\u001b[39m{\u001b[39;00mbest_epoch\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/ignite.py:233\u001b[0m, in \u001b[0;36mIgnite.run\u001b[0;34m(self, datasets, dataloader_creator, dataloaders, val_interval, early_stopper_kwargs, resume, check_initial_score, **trainer_kwargs)\u001b[0m\n\u001b[1;32m    230\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mload_checkpoint(resume)\n\u001b[1;32m    232\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m i_g\u001b[39m.\u001b[39mis_done(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtrainer, max_epochs):\n\u001b[0;32m--> 233\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mtrainer\u001b[39m.\u001b[39;49mrun(dataloaders[\u001b[39m\"\u001b[39;49m\u001b[39mtrain\u001b[39;49m\u001b[39m\"\u001b[39;49m], \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mtrainer_kwargs)\n\u001b[1;32m    235\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mremove_temp_events()\n\u001b[1;32m    237\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mvalidator:\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:704\u001b[0m, in \u001b[0;36mEngine.run\u001b[0;34m(self, data, max_epochs, epoch_length, seed)\u001b[0m\n\u001b[1;32m    701\u001b[0m         \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mepoch_length should be provided if data is None\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m    703\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mdataloader \u001b[39m=\u001b[39m data\n\u001b[0;32m--> 704\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_internal_run()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:783\u001b[0m, in \u001b[0;36mEngine._internal_run\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    781\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_dataloader_iter \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m    782\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39merror(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mEngine run is terminating due to exception: \u001b[39m\u001b[39m{\u001b[39;00me\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[0;32m--> 783\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_handle_exception(e)\n\u001b[1;32m    785\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_dataloader_iter \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m    786\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:466\u001b[0m, in \u001b[0;36mEngine._handle_exception\u001b[0;34m(self, e)\u001b[0m\n\u001b[1;32m    464\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_fire_event(Events\u001b[39m.\u001b[39mEXCEPTION_RAISED, e)\n\u001b[1;32m    465\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 466\u001b[0m     \u001b[39mraise\u001b[39;00m e\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:745\u001b[0m, in \u001b[0;36mEngine._internal_run\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    743\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m    744\u001b[0m     start_time \u001b[39m=\u001b[39m time\u001b[39m.\u001b[39mtime()\n\u001b[0;32m--> 745\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_fire_event(Events\u001b[39m.\u001b[39;49mSTARTED)\n\u001b[1;32m    746\u001b[0m     \u001b[39mwhile\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mepoch \u001b[39m<\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mmax_epochs \u001b[39mand\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mshould_terminate:  \u001b[39m# type: ignore[operator]\u001b[39;00m\n\u001b[1;32m    747\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mepoch \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:421\u001b[0m, in \u001b[0;36mEngine._fire_event\u001b[0;34m(self, event_name, *event_args, **event_kwargs)\u001b[0m\n\u001b[1;32m    419\u001b[0m kwargs\u001b[39m.\u001b[39mupdate(event_kwargs)\n\u001b[1;32m    420\u001b[0m first, others \u001b[39m=\u001b[39m ((args[\u001b[39m0\u001b[39m],), args[\u001b[39m1\u001b[39m:]) \u001b[39mif\u001b[39;00m (args \u001b[39mand\u001b[39;00m args[\u001b[39m0\u001b[39m] \u001b[39m==\u001b[39m \u001b[39mself\u001b[39m) \u001b[39melse\u001b[39;00m ((), args)\n\u001b[0;32m--> 421\u001b[0m func(\u001b[39m*\u001b[39;49mfirst, \u001b[39m*\u001b[39;49m(event_args \u001b[39m+\u001b[39;49m others), \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/utils.py:30\u001b[0m, in \u001b[0;36mget_validation_runner.<locals>.run_validation\u001b[0;34m(engine)\u001b[0m\n\u001b[1;32m     28\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mrun_validation\u001b[39m(engine):\n\u001b[1;32m     29\u001b[0m     epoch \u001b[39m=\u001b[39m engine\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mepoch\n\u001b[0;32m---> 30\u001b[0m     collected_data \u001b[39m=\u001b[39m collect_from_dataloaders(collector, dataloaders, required_data)\n\u001b[1;32m     31\u001b[0m     score \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m     32\u001b[0m     \u001b[39mif\u001b[39;00m validator:\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/utils.py:53\u001b[0m, in \u001b[0;36mcollect_from_dataloaders\u001b[0;34m(collector, dataloaders, required_data)\u001b[0m\n\u001b[1;32m     51\u001b[0m curr_dataset \u001b[39m=\u001b[39m curr_dataloader\u001b[39m.\u001b[39mdataset\n\u001b[1;32m     52\u001b[0m iterable \u001b[39m=\u001b[39m curr_dataloader\u001b[39m.\u001b[39m\u001b[39m__iter__\u001b[39m()\n\u001b[0;32m---> 53\u001b[0m curr_collected \u001b[39m=\u001b[39m accumulate_collector_output(collector, iterable, k)\n\u001b[1;32m     54\u001b[0m c_f\u001b[39m.\u001b[39mval_collected_data_checks(curr_collected, curr_dataset)\n\u001b[1;32m     55\u001b[0m collected_data[k] \u001b[39m=\u001b[39m curr_collected\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/utils.py:98\u001b[0m, in \u001b[0;36maccumulate_collector_output\u001b[0;34m(collector, iterable, output_name)\u001b[0m\n\u001b[1;32m     96\u001b[0m accumulator \u001b[39m=\u001b[39m DictionaryAccumulator()\n\u001b[1;32m     97\u001b[0m accumulator\u001b[39m.\u001b[39mattach(collector, output_name)\n\u001b[0;32m---> 98\u001b[0m collector\u001b[39m.\u001b[39;49mrun(iterable)\n\u001b[1;32m     99\u001b[0m accumulator\u001b[39m.\u001b[39mdetach(collector)\n\u001b[1;32m    100\u001b[0m output \u001b[39m=\u001b[39m collector\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mmetrics[output_name]\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:704\u001b[0m, in \u001b[0;36mEngine.run\u001b[0;34m(self, data, max_epochs, epoch_length, seed)\u001b[0m\n\u001b[1;32m    701\u001b[0m         \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mepoch_length should be provided if data is None\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m    703\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mdataloader \u001b[39m=\u001b[39m data\n\u001b[0;32m--> 704\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_internal_run()\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:783\u001b[0m, in \u001b[0;36mEngine._internal_run\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    781\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_dataloader_iter \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m    782\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39merror(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mEngine run is terminating due to exception: \u001b[39m\u001b[39m{\u001b[39;00me\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[0;32m--> 783\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_handle_exception(e)\n\u001b[1;32m    785\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_dataloader_iter \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m    786\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:466\u001b[0m, in \u001b[0;36mEngine._handle_exception\u001b[0;34m(self, e)\u001b[0m\n\u001b[1;32m    464\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_fire_event(Events\u001b[39m.\u001b[39mEXCEPTION_RAISED, e)\n\u001b[1;32m    465\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 466\u001b[0m     \u001b[39mraise\u001b[39;00m e\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:753\u001b[0m, in \u001b[0;36mEngine._internal_run\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    750\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_dataloader_iter \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m    751\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_setup_engine()\n\u001b[0;32m--> 753\u001b[0m time_taken \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_run_once_on_dataset()\n\u001b[1;32m    754\u001b[0m \u001b[39m# time is available for handlers but must be update after fire\u001b[39;00m\n\u001b[1;32m    755\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39mtimes[Events\u001b[39m.\u001b[39mEPOCH_COMPLETED\u001b[39m.\u001b[39mname] \u001b[39m=\u001b[39m time_taken\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:854\u001b[0m, in \u001b[0;36mEngine._run_once_on_dataset\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    852\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m    853\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mlogger\u001b[39m.\u001b[39merror(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mCurrent run is terminating due to exception: \u001b[39m\u001b[39m{\u001b[39;00me\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[0;32m--> 854\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_handle_exception(e)\n\u001b[1;32m    856\u001b[0m \u001b[39mreturn\u001b[39;00m time\u001b[39m.\u001b[39mtime() \u001b[39m-\u001b[39m start_time\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:466\u001b[0m, in \u001b[0;36mEngine._handle_exception\u001b[0;34m(self, e)\u001b[0m\n\u001b[1;32m    464\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_fire_event(Events\u001b[39m.\u001b[39mEXCEPTION_RAISED, e)\n\u001b[1;32m    465\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 466\u001b[0m     \u001b[39mraise\u001b[39;00m e\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/engine/engine.py:840\u001b[0m, in \u001b[0;36mEngine._run_once_on_dataset\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    838\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39miteration \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n\u001b[1;32m    839\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_fire_event(Events\u001b[39m.\u001b[39mITERATION_STARTED)\n\u001b[0;32m--> 840\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mstate\u001b[39m.\u001b[39moutput \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_process_function(\u001b[39mself\u001b[39;49m, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mstate\u001b[39m.\u001b[39;49mbatch)\n\u001b[1;32m    841\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_fire_event(Events\u001b[39m.\u001b[39mITERATION_COMPLETED)\n\u001b[1;32m    843\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mshould_terminate \u001b[39mor\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mshould_terminate_single_epoch:\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/ignite.py:332\u001b[0m, in \u001b[0;36mIgnite.get_collector_step.<locals>.collector_step\u001b[0;34m(engine, batch)\u001b[0m\n\u001b[1;32m    330\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcollector_step\u001b[39m(engine, batch):\n\u001b[1;32m    331\u001b[0m     batch \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mbatch_to_device(batch, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mdevice)\n\u001b[0;32m--> 332\u001b[0m     \u001b[39mreturn\u001b[39;00m f_utils\u001b[39m.\u001b[39;49mcollector_step(inference, batch, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mval_output_dict_fn)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/utils.py:33\u001b[0m, in \u001b[0;36mcollector_step\u001b[0;34m(inference, batch, output_dict_fn)\u001b[0m\n\u001b[1;32m     31\u001b[0m data \u001b[39m=\u001b[39m extract_data(batch)\n\u001b[1;32m     32\u001b[0m \u001b[39mwith\u001b[39;00m torch\u001b[39m.\u001b[39mno_grad():\n\u001b[0;32m---> 33\u001b[0m     f_dict \u001b[39m=\u001b[39m inference(data[\u001b[39m\"\u001b[39;49m\u001b[39mimgs\u001b[39;49m\u001b[39m\"\u001b[39;49m], domain\u001b[39m=\u001b[39;49mdata[\u001b[39m\"\u001b[39;49m\u001b[39mdomain\u001b[39;49m\u001b[39m\"\u001b[39;49m])\n\u001b[1;32m     34\u001b[0m data\u001b[39m.\u001b[39mpop(\u001b[39m\"\u001b[39m\u001b[39mimgs\u001b[39m\u001b[39m\"\u001b[39m)  \u001b[39m# we don't want to collect imgs\u001b[39;00m\n\u001b[1;32m     35\u001b[0m f_dict \u001b[39m=\u001b[39m output_dict_fn(f_dict)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/adapters/base_adapter.py:120\u001b[0m, in \u001b[0;36mBaseAdapter.inference\u001b[0;34m(self, x, domain)\u001b[0m\n\u001b[1;32m    109\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39minference\u001b[39m(\n\u001b[1;32m    110\u001b[0m     \u001b[39mself\u001b[39m, x: torch\u001b[39m.\u001b[39mTensor, domain: \u001b[39mint\u001b[39m \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m    111\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m Tuple[torch\u001b[39m.\u001b[39mTensor, torch\u001b[39m.\u001b[39mTensor]:\n\u001b[1;32m    112\u001b[0m     \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m    113\u001b[0m \u001b[39m    Arguments:\u001b[39;00m\n\u001b[1;32m    114\u001b[0m \u001b[39m        x: The input to the model\u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    118\u001b[0m \u001b[39m        Features and logits\u001b[39;00m\n\u001b[1;32m    119\u001b[0m \u001b[39m    \"\"\"\u001b[39;00m\n\u001b[0;32m--> 120\u001b[0m     \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49minference_fn(\n\u001b[1;32m    121\u001b[0m         x\u001b[39m=\u001b[39;49mx,\n\u001b[1;32m    122\u001b[0m         domain\u001b[39m=\u001b[39;49mdomain,\n\u001b[1;32m    123\u001b[0m         models\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mmodels,\n\u001b[1;32m    124\u001b[0m         misc\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mmisc,\n\u001b[1;32m    125\u001b[0m     )\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/inference/inference.py:145\u001b[0m, in \u001b[0;36mmcd_fn\u001b[0;34m(x, models, get_all, **kwargs)\u001b[0m\n\u001b[1;32m    140\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mmcd_fn\u001b[39m(x, models, get_all\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[1;32m    141\u001b[0m     \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m    142\u001b[0m \u001b[39m    Returns:\u001b[39;00m\n\u001b[1;32m    143\u001b[0m \u001b[39m        Features and logits, where ```logits = sum(C(features))```.\u001b[39;00m\n\u001b[1;32m    144\u001b[0m \u001b[39m    \"\"\"\u001b[39;00m\n\u001b[0;32m--> 145\u001b[0m     features \u001b[39m=\u001b[39m models[\u001b[39m\"\u001b[39;49m\u001b[39mG\u001b[39;49m\u001b[39m\"\u001b[39;49m](x)\n\u001b[1;32m    146\u001b[0m     logits_list \u001b[39m=\u001b[39m models[\u001b[39m\"\u001b[39m\u001b[39mC\u001b[39m\u001b[39m\"\u001b[39m](features)\n\u001b[1;32m    147\u001b[0m     logits \u001b[39m=\u001b[39m \u001b[39msum\u001b[39m(logits_list)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/modules/module.py:889\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m    887\u001b[0m     result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_slow_forward(\u001b[39m*\u001b[39m\u001b[39minput\u001b[39m, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[1;32m    888\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 889\u001b[0m     result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mforward(\u001b[39m*\u001b[39;49m\u001b[39minput\u001b[39;49m, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m    890\u001b[0m \u001b[39mfor\u001b[39;00m hook \u001b[39min\u001b[39;00m itertools\u001b[39m.\u001b[39mchain(\n\u001b[1;32m    891\u001b[0m         _global_forward_hooks\u001b[39m.\u001b[39mvalues(),\n\u001b[1;32m    892\u001b[0m         \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_forward_hooks\u001b[39m.\u001b[39mvalues()):\n\u001b[1;32m    893\u001b[0m     hook_result \u001b[39m=\u001b[39m hook(\u001b[39mself\u001b[39m, \u001b[39minput\u001b[39m, result)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py:157\u001b[0m, in \u001b[0;36mDataParallel.forward\u001b[0;34m(self, *inputs, **kwargs)\u001b[0m\n\u001b[1;32m    152\u001b[0m     \u001b[39mif\u001b[39;00m t\u001b[39m.\u001b[39mdevice \u001b[39m!=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39msrc_device_obj:\n\u001b[1;32m    153\u001b[0m         \u001b[39mraise\u001b[39;00m \u001b[39mRuntimeError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mmodule must have its parameters and buffers \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m    154\u001b[0m                            \u001b[39m\"\u001b[39m\u001b[39mon device \u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m (device_ids[0]) but found one of \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m    155\u001b[0m                            \u001b[39m\"\u001b[39m\u001b[39mthem on device: \u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39mformat(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39msrc_device_obj, t\u001b[39m.\u001b[39mdevice))\n\u001b[0;32m--> 157\u001b[0m inputs, kwargs \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mscatter(inputs, kwargs, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mdevice_ids)\n\u001b[1;32m    158\u001b[0m \u001b[39m# for forward function without any inputs, empty list and dict will be created\u001b[39;00m\n\u001b[1;32m    159\u001b[0m \u001b[39m# so the module can be executed on one device which is the first one in device_ids\u001b[39;00m\n\u001b[1;32m    160\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m inputs \u001b[39mand\u001b[39;00m \u001b[39mnot\u001b[39;00m kwargs:\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py:174\u001b[0m, in \u001b[0;36mDataParallel.scatter\u001b[0;34m(self, inputs, kwargs, device_ids)\u001b[0m\n\u001b[1;32m    173\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mscatter\u001b[39m(\u001b[39mself\u001b[39m, inputs, kwargs, device_ids):\n\u001b[0;32m--> 174\u001b[0m     \u001b[39mreturn\u001b[39;00m scatter_kwargs(inputs, kwargs, device_ids, dim\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mdim)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py:44\u001b[0m, in \u001b[0;36mscatter_kwargs\u001b[0;34m(inputs, kwargs, target_gpus, dim)\u001b[0m\n\u001b[1;32m     42\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mscatter_kwargs\u001b[39m(inputs, kwargs, target_gpus, dim\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m):\n\u001b[1;32m     43\u001b[0m     \u001b[39mr\u001b[39m\u001b[39m\"\"\"Scatter with support for kwargs dictionary\"\"\"\u001b[39;00m\n\u001b[0;32m---> 44\u001b[0m     inputs \u001b[39m=\u001b[39m scatter(inputs, target_gpus, dim) \u001b[39mif\u001b[39;00m inputs \u001b[39melse\u001b[39;00m []\n\u001b[1;32m     45\u001b[0m     kwargs \u001b[39m=\u001b[39m scatter(kwargs, target_gpus, dim) \u001b[39mif\u001b[39;00m kwargs \u001b[39melse\u001b[39;00m []\n\u001b[1;32m     46\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39mlen\u001b[39m(inputs) \u001b[39m<\u001b[39m \u001b[39mlen\u001b[39m(kwargs):\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py:36\u001b[0m, in \u001b[0;36mscatter\u001b[0;34m(inputs, target_gpus, dim)\u001b[0m\n\u001b[1;32m     30\u001b[0m \u001b[39m# After scatter_map is called, a scatter_map cell will exist. This cell\u001b[39;00m\n\u001b[1;32m     31\u001b[0m \u001b[39m# has a reference to the actual function scatter_map, which has references\u001b[39;00m\n\u001b[1;32m     32\u001b[0m \u001b[39m# to a closure that has a reference to the scatter_map cell (because the\u001b[39;00m\n\u001b[1;32m     33\u001b[0m \u001b[39m# fn is recursive). To avoid this reference cycle, we set the function to\u001b[39;00m\n\u001b[1;32m     34\u001b[0m \u001b[39m# None, clearing the cell\u001b[39;00m\n\u001b[1;32m     35\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m---> 36\u001b[0m     res \u001b[39m=\u001b[39m scatter_map(inputs)\n\u001b[1;32m     37\u001b[0m \u001b[39mfinally\u001b[39;00m:\n\u001b[1;32m     38\u001b[0m     scatter_map \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py:23\u001b[0m, in \u001b[0;36mscatter.<locals>.scatter_map\u001b[0;34m(obj)\u001b[0m\n\u001b[1;32m     21\u001b[0m     \u001b[39mreturn\u001b[39;00m [\u001b[39mtype\u001b[39m(obj)(\u001b[39m*\u001b[39margs) \u001b[39mfor\u001b[39;00m args \u001b[39min\u001b[39;00m \u001b[39mzip\u001b[39m(\u001b[39m*\u001b[39m\u001b[39mmap\u001b[39m(scatter_map, obj))]\n\u001b[1;32m     22\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(obj, \u001b[39mtuple\u001b[39m) \u001b[39mand\u001b[39;00m \u001b[39mlen\u001b[39m(obj) \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m:\n\u001b[0;32m---> 23\u001b[0m     \u001b[39mreturn\u001b[39;00m \u001b[39mlist\u001b[39m(\u001b[39mzip\u001b[39;49m(\u001b[39m*\u001b[39;49m\u001b[39mmap\u001b[39;49m(scatter_map, obj)))\n\u001b[1;32m     24\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(obj, \u001b[39mlist\u001b[39m) \u001b[39mand\u001b[39;00m \u001b[39mlen\u001b[39m(obj) \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m:\n\u001b[1;32m     25\u001b[0m     \u001b[39mreturn\u001b[39;00m [\u001b[39mlist\u001b[39m(i) \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m \u001b[39mzip\u001b[39m(\u001b[39m*\u001b[39m\u001b[39mmap\u001b[39m(scatter_map, obj))]\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/scatter_gather.py:19\u001b[0m, in \u001b[0;36mscatter.<locals>.scatter_map\u001b[0;34m(obj)\u001b[0m\n\u001b[1;32m     17\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mscatter_map\u001b[39m(obj):\n\u001b[1;32m     18\u001b[0m     \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(obj, torch\u001b[39m.\u001b[39mTensor):\n\u001b[0;32m---> 19\u001b[0m         \u001b[39mreturn\u001b[39;00m Scatter\u001b[39m.\u001b[39;49mapply(target_gpus, \u001b[39mNone\u001b[39;49;00m, dim, obj)\n\u001b[1;32m     20\u001b[0m     \u001b[39mif\u001b[39;00m is_namedtuple(obj):\n\u001b[1;32m     21\u001b[0m         \u001b[39mreturn\u001b[39;00m [\u001b[39mtype\u001b[39m(obj)(\u001b[39m*\u001b[39margs) \u001b[39mfor\u001b[39;00m args \u001b[39min\u001b[39;00m \u001b[39mzip\u001b[39m(\u001b[39m*\u001b[39m\u001b[39mmap\u001b[39m(scatter_map, obj))]\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/_functions.py:93\u001b[0m, in \u001b[0;36mScatter.forward\u001b[0;34m(ctx, target_gpus, chunk_sizes, dim, input)\u001b[0m\n\u001b[1;32m     90\u001b[0m \u001b[39mif\u001b[39;00m torch\u001b[39m.\u001b[39mcuda\u001b[39m.\u001b[39mis_available() \u001b[39mand\u001b[39;00m ctx\u001b[39m.\u001b[39minput_device \u001b[39m==\u001b[39m \u001b[39m-\u001b[39m\u001b[39m1\u001b[39m:\n\u001b[1;32m     91\u001b[0m     \u001b[39m# Perform CPU to GPU copies in a background stream\u001b[39;00m\n\u001b[1;32m     92\u001b[0m     streams \u001b[39m=\u001b[39m [_get_stream(device) \u001b[39mfor\u001b[39;00m device \u001b[39min\u001b[39;00m target_gpus]\n\u001b[0;32m---> 93\u001b[0m outputs \u001b[39m=\u001b[39m comm\u001b[39m.\u001b[39;49mscatter(\u001b[39minput\u001b[39;49m, target_gpus, chunk_sizes, ctx\u001b[39m.\u001b[39;49mdim, streams)\n\u001b[1;32m     94\u001b[0m \u001b[39m# Synchronize with the copy stream\u001b[39;00m\n\u001b[1;32m     95\u001b[0m \u001b[39mif\u001b[39;00m streams \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/parallel/comm.py:189\u001b[0m, in \u001b[0;36mscatter\u001b[0;34m(tensor, devices, chunk_sizes, dim, streams, out)\u001b[0m\n\u001b[1;32m    187\u001b[0m \u001b[39mif\u001b[39;00m out \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m    188\u001b[0m     devices \u001b[39m=\u001b[39m [_get_device_index(d) \u001b[39mfor\u001b[39;00m d \u001b[39min\u001b[39;00m devices]\n\u001b[0;32m--> 189\u001b[0m     \u001b[39mreturn\u001b[39;00m \u001b[39mtuple\u001b[39m(torch\u001b[39m.\u001b[39;49m_C\u001b[39m.\u001b[39;49m_scatter(tensor, devices, chunk_sizes, dim, streams))\n\u001b[1;32m    190\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m    191\u001b[0m     \u001b[39mif\u001b[39;00m devices \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n",
      "\u001b[0;31mRuntimeError\u001b[0m: CUDA error: out of memory"
     ]
    }
   ],
   "source": [
    "logging.getLogger(\"pytorch-adapt\").setLevel(logging.WARNING)\n",
    "\n",
    "early_stopper_kwargs = {\"patience\":2}\n",
    "\n",
    "\n",
    "best_score, best_epoch = trainer.run(\n",
    "    datasets, dataloader_creator=dc, max_epochs=5, check_initial_score=True, early_stopper_kwargs=early_stopper_kwargs\n",
    ")\n",
    "print(f\"best_score={best_score}, best_epoch={best_epoch}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 27204 characters]",
      "text/plain": [
       "<Figure size 600x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 36200 characters]",
      "text/plain": [
       "<Figure size 600x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31mThe Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
     ]
    }
   ],
   "source": [
    "plt.plot(validator.score_history[1:])\n",
    "plt.title(\"score_history\")\n",
    "plt.show()\n",
    "\n",
    "plt.plot(val_hooks[0].score_history[1:], label='source')\n",
    "plt.plot(val_hooks[1].score_history[1:], label='target')\n",
    "plt.legend()\n",
    "plt.title(\"src, target val accuracy\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "validator score history [2.85106766 1.07307923 1.06300926 1.43146741 1.88468337 1.96975768\n",
      " 2.14979064 2.62666798 2.61236888 2.4836719  2.59688711 2.05844843\n",
      " 2.02083945 2.18156433 2.30989116 2.43664771 2.50495136 2.57028472\n",
      " 2.55985087 2.59315497 2.65624613]\n",
      "src_val accuracy history [0.90425533 0.20921986 0.40602836 0.52482271 0.49822694 0.5673759\n",
      " 0.57624114 0.59042555 0.59751773 0.57978725 0.63297874 0.57446808\n",
      " 0.65602839 0.66312057 0.66489363 0.66666669 0.65957445 0.65957445\n",
      " 0.67730498 0.67375886 0.66666669]\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:pytorch-adapt:***EVALUATING BEST MODEL***\n",
      "INFO:pytorch-adapt:Collecting target_val_with_labels\n",
      "INFO:pytorch-adapt:Setting models to eval() mode\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4980a70229194e1eb8fee18c5af651c1",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "[1/5]  20%|##        |it [00:00<?]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.48427674174308777\n"
     ]
    }
   ],
   "source": [
    "validator = AccuracyValidator(key_map={\"target_val_with_labels\": \"src_val\"})\n",
    "score = trainer.evaluate_best_model(datasets, validator, dc)\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:pytorch-adapt:***EVALUATING BEST MODEL***\n",
      "INFO:pytorch-adapt:Collecting src_val\n",
      "INFO:pytorch-adapt:Setting models to eval() mode\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c372abf93f1e4808b286822e23a49261",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "[1/18]   6%|5         |it [00:00<?]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6666666865348816\n"
     ]
    }
   ],
   "source": [
    "validator = AccuracyValidator(key_map={\"src_val\": \"src_val\"})\n",
    "score = trainer.evaluate_best_model(datasets, validator, dc)\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### LOAD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = \"/media/10TB71/shashemi/Domain-Adaptation/results/DAModels.CORAL/0/w2d/saved_models/checkpointer_49.pt\"\n",
    "base_path = \"/media/10TB71/shashemi/Domain-Adaptation/results/DAModels.CORAL/0/w2d/saved_models/\"\n",
    "checkpoint = torch.load(path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "base_path = \"/media/10TB71/shashemi/Domain-Adaptation/results/DAModels.DANN/0/w2a/saved_models/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-05-25 17:32:04,308 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n",
      "2021-05-25 17:32:04,309 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n",
      "2021-05-25 17:32:04,311 ignite.distributed.auto.auto_model INFO: Apply torch DataParallel on model\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import torch\n",
    "import os\n",
    "import gc\n",
    "from datetime import datetime\n",
    "\n",
    "from pytorch_adapt.datasets import DataloaderCreator, get_office31\n",
    "from pytorch_adapt.frameworks.ignite import CheckpointFnCreator, Ignite\n",
    "from pytorch_adapt.validators import AccuracyValidator, IMValidator, ScoreHistory, DiversityValidator, EntropyValidator, MultipleValidators\n",
    "\n",
    "from models import get_model\n",
    "from utils import DAModels\n",
    "\n",
    "from pytorch_adapt.frameworks.ignite import (\n",
    "    CheckpointFnCreator,\n",
    "    IgniteValHookWrapper,\n",
    "    checkpoint_utils,\n",
    ")\n",
    "\n",
    "checkpoint_fn = CheckpointFnCreator(dirname=base_path, require_empty=False, n_saved=None)\n",
    "    \n",
    "    \n",
    "sourceAccuracyValidator = AccuracyValidator()\n",
    "validators = {\n",
    "    \"entropy\": EntropyValidator(),\n",
    "    \"diversity\": DiversityValidator(),\n",
    "    # \"accuracy\": sourceAccuracyValidator,\n",
    "}\n",
    "validator = ScoreHistory(MultipleValidators(validators))\n",
    "\n",
    "\n",
    "targetAccuracyValidator = AccuracyValidator(key_map={\"target_val_with_labels\": \"src_val\"})\n",
    "\n",
    "\n",
    "val_hooks = [ScoreHistory(sourceAccuracyValidator), \n",
    "            ScoreHistory(targetAccuracyValidator)]\n",
    "\n",
    "source_domain =\"webcam\"\n",
    "target_domain = \"amazon\"\n",
    "\n",
    "G = office31G(pretrained=True, model_dir=weights_root).to(device)\n",
    "C = office31C(domain=source_domain, pretrained=True,\n",
    "                model_dir=weights_root).to(device)\n",
    "D = Discriminator(in_size=2048, h=1024).to(device)\n",
    "\n",
    "optimizers = Optimizers((torch.optim.Adam, {\"lr\": 1e-4}))\n",
    "lr_schedulers = LRSchedulers((torch.optim.lr_scheduler.ExponentialLR, {\"gamma\": 0.99}))\n",
    "\n",
    "\n",
    "models = Models({\"G\": G, \"C\": C, \"D\": D})\n",
    "adapter = DANN(models=models, optimizers=optimizers, lr_schedulers=lr_schedulers)\n",
    "\n",
    "\n",
    "trainer = Ignite(\n",
    "    adapter, validator=validator, val_hooks=val_hooks, checkpoint_fn=checkpoint_fn\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "ename": "RuntimeError",
     "evalue": "Error(s) in loading state_dict for DataParallel:\n\tMissing key(s) in state_dict: \"module.conv1.weight\", \"module.bn1.weight\", \"module.bn1.bias\", \"module.bn1.running_mean\", \"module.bn1.running_var\", \"module.layer1.0.conv1.weight\", \"module.layer1.0.bn1.weight\", \"module.layer1.0.bn1.bias\", \"module.layer1.0.bn1.running_mean\", \"module.layer1.0.bn1.running_var\", \"module.layer1.0.conv2.weight\", \"module.layer1.0.bn2.weight\", \"module.layer1.0.bn2.bias\", \"module.layer1.0.bn2.running_mean\", \"module.layer1.0.bn2.running_var\", \"module.layer1.0.conv3.weight\", \"module.layer1.0.bn3.weight\", \"module.layer1.0.bn3.bias\", \"module.layer1.0.bn3.running_mean\", \"module.layer1.0.bn3.running_var\", \"module.layer1.0.downsample.0.weight\", \"module.layer1.0.downsample.1.weight\", \"module.layer1.0.downsample.1.bias\", \"module.layer1.0.downsample.1.running_mean\", \"module.layer1.0.downsample.1.running_var\", \"module.layer1.1.conv1.weight\", \"module.layer1.1.bn1.weight\", \"module.layer1.1.bn1.bias\", \"module.layer1.1.bn1.running_mean\", \"module.layer1.1.bn1.running_var\", \"module.layer1.1.conv2.weight\", \"module.layer1.1.bn2.weight\", \"module.layer1.1.bn2.bias\", \"module.layer1.1.bn2.running_mean\", \"module.layer1.1.bn2.running_var\", \"module.layer1.1.conv3.weight\", \"module.layer1.1.bn3.weight\", \"module.layer1.1.bn3.bias\", \"module.layer1.1.bn3.running_mean\", \"module.layer1.1.bn3.running_var\", \"module.layer1.2.conv1.weight\", \"module.layer1.2.bn1.weight\", \"module.layer1.2.bn1.bias\", \"module.layer1.2.bn1.running_mean\", \"module.layer1.2.bn1.running_var\", \"module.layer1.2.conv2.weight\", \"module.layer1.2.bn2.weight\", \"module.layer1.2.bn2.bias\", \"module.layer1.2.bn2.running_mean\", \"module.layer1.2.bn2.running_var\", \"module.layer1.2.conv3.weight\", \"module.layer1.2.bn3.weight\", \"module.layer1.2.bn3.bias\", \"module.layer1.2.bn3.running_mean\", \"module.layer1.2.bn3.running_var\", \"module.layer2.0.conv1.weight\", \"module.layer2.0.bn1.weight\", \"module.layer2.0.bn1.bias\", \"module.layer2.0.bn1.running_mean\", \"module.layer2.0.bn1.running_var\", \"module.layer2.0.conv2.weight\", \"module.layer2.0.bn2.weight\", \"module.layer2.0.bn2.bias\", \"module.layer2.0.bn2.running_mean\", \"module.layer2.0.bn2.running_var\", \"module.layer2.0.conv3.weight\", \"module.layer2.0.bn3.weight\", \"module.layer2.0.bn3.bias\", \"module.layer2.0.bn3.running_mean\", \"module.layer2.0.bn3.running_var\", \"module.layer2.0.downsample.0.weight\", \"module.layer2.0.downsample.1.weight\", \"module.layer2.0.downsample.1.bias\", \"module.layer2.0.downsample.1.running_mean\", \"module.layer2.0.downsample.1.running_var\", \"module.layer2.1.conv1.weight\", \"module.layer2.1.bn1.weight\", \"module.layer2.1.bn1.bias\", \"module.layer2.1.bn1.running_mean\", \"module.layer2.1.bn1.running_var\", \"module.layer2.1.conv2.weight\", \"module.layer2.1.bn2.weight\", \"module.layer2.1.bn2.bias\", \"module.layer2.1.bn2.running_mean\", \"module.layer2.1.bn2.running_var\", \"module.layer2.1.conv3.weight\", \"module.layer2.1.bn3.weight\", \"module.layer2.1.bn3.bias\", \"module.layer2.1.bn3.running_mean\", \"module.layer2.1.bn3.running_var\", \"module.layer2.2.conv1.weight\", \"module.layer2.2.bn1.weight\", \"module.layer2.2.bn1.bias\", \"module.layer2.2.bn1.running_mean\", \"module.layer2.2.bn1.running_var\", \"module.layer2.2.conv2.weight\", \"module.layer2.2.bn2.weight\", \"module.layer2.2.bn2.bias\", \"module.layer2.2.bn2.running_mean\", \"module.layer2.2.bn2.running_var\", \"module.layer2.2.conv3.weight\", \"module.layer2.2.bn3.weight\", \"module.layer2.2.bn3.bias\", \"module.layer2.2.bn3.running_mean\", \"module.layer2.2.bn3.running_var\", \"module.layer2.3.conv1.weight\", \"module.layer2.3.bn1.weight\", \"module.layer2.3.bn1.bias\", \"module.layer2.3.bn1.running_mean\", \"module.layer2.3.bn1.running_var\", \"module.layer2.3.conv2.weight\", \"module.layer2.3.bn2.weight\", \"module.layer2.3.bn2.bias\", \"module.layer2.3.bn2.running_mean\", \"module.layer2.3.bn2.running_var\", \"module.layer2.3.conv3.weight\", \"module.layer2.3.bn3.weight\", \"module.layer2.3.bn3.bias\", \"module.layer2.3.bn3.running_mean\", \"module.layer2.3.bn3.running_var\", \"module.layer3.0.conv1.weight\", \"module.layer3.0.bn1.weight\", \"module.layer3.0.bn1.bias\", \"module.layer3.0.bn1.running_mean\", \"module.layer3.0.bn1.running_var\", \"module.layer3.0.conv2.weight\", \"module.layer3.0.bn2.weight\", \"module.layer3.0.bn2.bias\", \"module.layer3.0.bn2.running_mean\", \"module.layer3.0.bn2.running_var\", \"module.layer3.0.conv3.weight\", \"module.layer3.0.bn3.weight\", \"module.layer3.0.bn3.bias\", \"module.layer3.0.bn3.running_mean\", \"module.layer3.0.bn3.running_var\", \"module.layer3.0.downsample.0.weight\", \"module.layer3.0.downsample.1.weight\", \"module.layer3.0.downsample.1.bias\", \"module.layer3.0.downsample.1.running_mean\", \"module.layer3.0.downsample.1.running_var\", \"module.layer3.1.conv1.weight\", \"module.layer3.1.bn1.weight\", \"module.layer3.1.bn1.bias\", \"module.layer3.1.bn1.running_mean\", \"module.layer3.1.bn1.running_var\", \"module.layer3.1.conv2.weight\", \"module.layer3.1.bn2.weight\", \"module.layer3.1.bn2.bias\", \"module.layer3.1.bn2.running_mean\", \"module.layer3.1.bn2.running_var\", \"module.layer3.1.conv3.weight\", \"module.layer3.1.bn3.weight\", \"module.layer3.1.bn3.bias\", \"module.layer3.1.bn3.running_mean\", \"module.layer3.1.bn3.running_var\", \"module.layer3.2.conv1.weight\", \"module.layer3.2.bn1.weight\", \"module.layer3.2.bn1.bias\", \"module.layer3.2.bn1.running_mean\", \"module.layer3.2.bn1.running_var\", \"module.layer3.2.conv2.weight\", \"module.layer3.2.bn2.weight\", \"module.layer3.2.bn2.bias\", \"module.layer3.2.bn2.running_mean\", \"module.layer3.2.bn2.running_var\", \"module.layer3.2.conv3.weight\", \"module.layer3.2.bn3.weight\", \"module.layer3.2.bn3.bias\", \"module.layer3.2.bn3.running_mean\", \"module.layer3.2.bn3.running_var\", \"module.layer3.3.conv1.weight\", \"module.layer3.3.bn1.weight\", \"module.layer3.3.bn1.bias\", \"module.layer3.3.bn1.running_mean\", \"module.layer3.3.bn1.running_var\", \"module.layer3.3.conv2.weight\", \"module.layer3.3.bn2.weight\", \"module.layer3.3.bn2.bias\", \"module.layer3.3.bn2.running_mean\", \"module.layer3.3.bn2.running_var\", \"module.layer3.3.conv3.weight\", \"module.layer3.3.bn3.weight\", \"module.layer3.3.bn3.bias\", \"module.layer3.3.bn3.running_mean\", \"module.layer3.3.bn3.running_var\", \"module.layer3.4.conv1.weight\", \"module.layer3.4.bn1.weight\", \"module.layer3.4.bn1.bias\", \"module.layer3.4.bn1.running_mean\", \"module.layer3.4.bn1.running_var\", \"module.layer3.4.conv2.weight\", \"module.layer3.4.bn2.weight\", \"module.layer3.4.bn2.bias\", \"module.layer3.4.bn2.running_mean\", \"module.layer3.4.bn2.running_var\", \"module.layer3.4.conv3.weight\", \"module.layer3.4.bn3.weight\", \"module.layer3.4.bn3.bias\", \"module.layer3.4.bn3.running_mean\", \"module.layer3.4.bn3.running_var\", \"module.layer3.5.conv1.weight\", \"module.layer3.5.bn1.weight\", \"module.layer3.5.bn1.bias\", \"module.layer3.5.bn1.running_mean\", \"module.layer3.5.bn1.running_var\", \"module.layer3.5.conv2.weight\", \"module.layer3.5.bn2.weight\", \"module.layer3.5.bn2.bias\", \"module.layer3.5.bn2.running_mean\", \"module.layer3.5.bn2.running_var\", \"module.layer3.5.conv3.weight\", \"module.layer3.5.bn3.weight\", \"module.layer3.5.bn3.bias\", \"module.layer3.5.bn3.running_mean\", \"module.layer3.5.bn3.running_var\", \"module.layer4.0.conv1.weight\", \"module.layer4.0.bn1.weight\", \"module.layer4.0.bn1.bias\", \"module.layer4.0.bn1.running_mean\", \"module.layer4.0.bn1.running_var\", \"module.layer4.0.conv2.weight\", \"module.layer4.0.bn2.weight\", \"module.layer4.0.bn2.bias\", \"module.layer4.0.bn2.running_mean\", \"module.layer4.0.bn2.running_var\", \"module.layer4.0.conv3.weight\", \"module.layer4.0.bn3.weight\", \"module.layer4.0.bn3.bias\", \"module.layer4.0.bn3.running_mean\", \"module.layer4.0.bn3.running_var\", \"module.layer4.0.downsample.0.weight\", \"module.layer4.0.downsample.1.weight\", \"module.layer4.0.downsample.1.bias\", \"module.layer4.0.downsample.1.running_mean\", \"module.layer4.0.downsample.1.running_var\", \"module.layer4.1.conv1.weight\", \"module.layer4.1.bn1.weight\", \"module.layer4.1.bn1.bias\", \"module.layer4.1.bn1.running_mean\", \"module.layer4.1.bn1.running_var\", \"module.layer4.1.conv2.weight\", \"module.layer4.1.bn2.weight\", \"module.layer4.1.bn2.bias\", \"module.layer4.1.bn2.running_mean\", \"module.layer4.1.bn2.running_var\", \"module.layer4.1.conv3.weight\", \"module.layer4.1.bn3.weight\", \"module.layer4.1.bn3.bias\", \"module.layer4.1.bn3.running_mean\", \"module.layer4.1.bn3.running_var\", \"module.layer4.2.conv1.weight\", \"module.layer4.2.bn1.weight\", \"module.layer4.2.bn1.bias\", \"module.layer4.2.bn1.running_mean\", \"module.layer4.2.bn1.running_var\", \"module.layer4.2.conv2.weight\", \"module.layer4.2.bn2.weight\", \"module.layer4.2.bn2.bias\", \"module.layer4.2.bn2.running_mean\", \"module.layer4.2.bn2.running_var\", \"module.layer4.2.conv3.weight\", \"module.layer4.2.bn3.weight\", \"module.layer4.2.bn3.bias\", \"module.layer4.2.bn3.running_mean\", \"module.layer4.2.bn3.running_var\". \n\tUnexpected key(s) in state_dict: \"conv1.weight\", \"bn1.weight\", \"bn1.bias\", \"bn1.running_mean\", \"bn1.running_var\", \"bn1.num_batches_tracked\", \"layer1.0.conv1.weight\", \"layer1.0.bn1.weight\", \"layer1.0.bn1.bias\", \"layer1.0.bn1.running_mean\", \"layer1.0.bn1.running_var\", \"layer1.0.bn1.num_batches_tracked\", \"layer1.0.conv2.weight\", \"layer1.0.bn2.weight\", \"layer1.0.bn2.bias\", \"layer1.0.bn2.running_mean\", \"layer1.0.bn2.running_var\", \"layer1.0.bn2.num_batches_tracked\", \"layer1.0.conv3.weight\", \"layer1.0.bn3.weight\", \"layer1.0.bn3.bias\", \"layer1.0.bn3.running_mean\", \"layer1.0.bn3.running_var\", \"layer1.0.bn3.num_batches_tracked\", \"layer1.0.downsample.0.weight\", \"layer1.0.downsample.1.weight\", \"layer1.0.downsample.1.bias\", \"layer1.0.downsample.1.running_mean\", \"layer1.0.downsample.1.running_var\", \"layer1.0.downsample.1.num_batches_tracked\", \"layer1.1.conv1.weight\", \"layer1.1.bn1.weight\", \"layer1.1.bn1.bias\", \"layer1.1.bn1.running_mean\", \"layer1.1.bn1.running_var\", \"layer1.1.bn1.num_batches_tracked\", \"layer1.1.conv2.weight\", \"layer1.1.bn2.weight\", \"layer1.1.bn2.bias\", \"layer1.1.bn2.running_mean\", \"layer1.1.bn2.running_var\", \"layer1.1.bn2.num_batches_tracked\", \"layer1.1.conv3.weight\", \"layer1.1.bn3.weight\", \"layer1.1.bn3.bias\", \"layer1.1.bn3.running_mean\", \"layer1.1.bn3.running_var\", \"layer1.1.bn3.num_batches_tracked\", \"layer1.2.conv1.weight\", \"layer1.2.bn1.weight\", \"layer1.2.bn1.bias\", \"layer1.2.bn1.running_mean\", \"layer1.2.bn1.running_var\", \"layer1.2.bn1.num_batches_tracked\", \"layer1.2.conv2.weight\", \"layer1.2.bn2.weight\", \"layer1.2.bn2.bias\", \"layer1.2.bn2.running_mean\", \"layer1.2.bn2.running_var\", \"layer1.2.bn2.num_batches_tracked\", \"layer1.2.conv3.weight\", \"layer1.2.bn3.weight\", \"layer1.2.bn3.bias\", \"layer1.2.bn3.running_mean\", \"layer1.2.bn3.running_var\", \"layer1.2.bn3.num_batches_tracked\", \"layer2.0.conv1.weight\", \"layer2.0.bn1.weight\", \"layer2.0.bn1.bias\", \"layer2.0.bn1.running_mean\", \"layer2.0.bn1.running_var\", \"layer2.0.bn1.num_batches_tracked\", \"layer2.0.conv2.weight\", \"layer2.0.bn2.weight\", \"layer2.0.bn2.bias\", \"layer2.0.bn2.running_mean\", \"layer2.0.bn2.running_var\", \"layer2.0.bn2.num_batches_tracked\", \"layer2.0.conv3.weight\", \"layer2.0.bn3.weight\", \"layer2.0.bn3.bias\", \"layer2.0.bn3.running_mean\", \"layer2.0.bn3.running_var\", \"layer2.0.bn3.num_batches_tracked\", \"layer2.0.downsample.0.weight\", \"layer2.0.downsample.1.weight\", \"layer2.0.downsample.1.bias\", \"layer2.0.downsample.1.running_mean\", \"layer2.0.downsample.1.running_var\", \"layer2.0.downsample.1.num_batches_tracked\", \"layer2.1.conv1.weight\", \"layer2.1.bn1.weight\", \"layer2.1.bn1.bias\", \"layer2.1.bn1.running_mean\", \"layer2.1.bn1.running_var\", \"layer2.1.bn1.num_batches_tracked\", \"layer2.1.conv2.weight\", \"layer2.1.bn2.weight\", \"layer2.1.bn2.bias\", \"layer2.1.bn2.running_mean\", \"layer2.1.bn2.running_var\", \"layer2.1.bn2.num_batches_tracked\", \"layer2.1.conv3.weight\", \"layer2.1.bn3.weight\", \"layer2.1.bn3.bias\", \"layer2.1.bn3.running_mean\", \"layer2.1.bn3.running_var\", \"layer2.1.bn3.num_batches_tracked\", \"layer2.2.conv1.weight\", \"layer2.2.bn1.weight\", \"layer2.2.bn1.bias\", \"layer2.2.bn1.running_mean\", \"layer2.2.bn1.running_var\", \"layer2.2.bn1.num_batches_tracked\", \"layer2.2.conv2.weight\", \"layer2.2.bn2.weight\", \"layer2.2.bn2.bias\", \"layer2.2.bn2.running_mean\", \"layer2.2.bn2.running_var\", \"layer2.2.bn2.num_batches_tracked\", \"layer2.2.conv3.weight\", \"layer2.2.bn3.weight\", \"layer2.2.bn3.bias\", \"layer2.2.bn3.running_mean\", \"layer2.2.bn3.running_var\", \"layer2.2.bn3.num_batches_tracked\", \"layer2.3.conv1.weight\", \"layer2.3.bn1.weight\", \"layer2.3.bn1.bias\", \"layer2.3.bn1.running_mean\", \"layer2.3.bn1.running_var\", \"layer2.3.bn1.num_batches_tracked\", \"layer2.3.conv2.weight\", \"layer2.3.bn2.weight\", \"layer2.3.bn2.bias\", \"layer2.3.bn2.running_mean\", \"layer2.3.bn2.running_var\", \"layer2.3.bn2.num_batches_tracked\", \"layer2.3.conv3.weight\", \"layer2.3.bn3.weight\", \"layer2.3.bn3.bias\", \"layer2.3.bn3.running_mean\", \"layer2.3.bn3.running_var\", \"layer2.3.bn3.num_batches_tracked\", \"layer3.0.conv1.weight\", \"layer3.0.bn1.weight\", \"layer3.0.bn1.bias\", \"layer3.0.bn1.running_mean\", \"layer3.0.bn1.running_var\", \"layer3.0.bn1.num_batches_tracked\", \"layer3.0.conv2.weight\", \"layer3.0.bn2.weight\", \"layer3.0.bn2.bias\", \"layer3.0.bn2.running_mean\", \"layer3.0.bn2.running_var\", \"layer3.0.bn2.num_batches_tracked\", \"layer3.0.conv3.weight\", \"layer3.0.bn3.weight\", \"layer3.0.bn3.bias\", \"layer3.0.bn3.running_mean\", \"layer3.0.bn3.running_var\", \"layer3.0.bn3.num_batches_tracked\", \"layer3.0.downsample.0.weight\", \"layer3.0.downsample.1.weight\", \"layer3.0.downsample.1.bias\", \"layer3.0.downsample.1.running_mean\", \"layer3.0.downsample.1.running_var\", \"layer3.0.downsample.1.num_batches_tracked\", \"layer3.1.conv1.weight\", \"layer3.1.bn1.weight\", \"layer3.1.bn1.bias\", \"layer3.1.bn1.running_mean\", \"layer3.1.bn1.running_var\", \"layer3.1.bn1.num_batches_tracked\", \"layer3.1.conv2.weight\", \"layer3.1.bn2.weight\", \"layer3.1.bn2.bias\", \"layer3.1.bn2.running_mean\", \"layer3.1.bn2.running_var\", \"layer3.1.bn2.num_batches_tracked\", \"layer3.1.conv3.weight\", \"layer3.1.bn3.weight\", \"layer3.1.bn3.bias\", \"layer3.1.bn3.running_mean\", \"layer3.1.bn3.running_var\", \"layer3.1.bn3.num_batches_tracked\", \"layer3.2.conv1.weight\", \"layer3.2.bn1.weight\", \"layer3.2.bn1.bias\", \"layer3.2.bn1.running_mean\", \"layer3.2.bn1.running_var\", \"layer3.2.bn1.num_batches_tracked\", \"layer3.2.conv2.weight\", \"layer3.2.bn2.weight\", \"layer3.2.bn2.bias\", \"layer3.2.bn2.running_mean\", \"layer3.2.bn2.running_var\", \"layer3.2.bn2.num_batches_tracked\", \"layer3.2.conv3.weight\", \"layer3.2.bn3.weight\", \"layer3.2.bn3.bias\", \"layer3.2.bn3.running_mean\", \"layer3.2.bn3.running_var\", \"layer3.2.bn3.num_batches_tracked\", \"layer3.3.conv1.weight\", \"layer3.3.bn1.weight\", \"layer3.3.bn1.bias\", \"layer3.3.bn1.running_mean\", \"layer3.3.bn1.running_var\", \"layer3.3.bn1.num_batches_tracked\", \"layer3.3.conv2.weight\", \"layer3.3.bn2.weight\", \"layer3.3.bn2.bias\", \"layer3.3.bn2.running_mean\", \"layer3.3.bn2.running_var\", \"layer3.3.bn2.num_batches_tracked\", \"layer3.3.conv3.weight\", \"layer3.3.bn3.weight\", \"layer3.3.bn3.bias\", \"layer3.3.bn3.running_mean\", \"layer3.3.bn3.running_var\", \"layer3.3.bn3.num_batches_tracked\", \"layer3.4.conv1.weight\", \"layer3.4.bn1.weight\", \"layer3.4.bn1.bias\", \"layer3.4.bn1.running_mean\", \"layer3.4.bn1.running_var\", \"layer3.4.bn1.num_batches_tracked\", \"layer3.4.conv2.weight\", \"layer3.4.bn2.weight\", \"layer3.4.bn2.bias\", \"layer3.4.bn2.running_mean\", \"layer3.4.bn2.running_var\", \"layer3.4.bn2.num_batches_tracked\", \"layer3.4.conv3.weight\", \"layer3.4.bn3.weight\", \"layer3.4.bn3.bias\", \"layer3.4.bn3.running_mean\", \"layer3.4.bn3.running_var\", \"layer3.4.bn3.num_batches_tracked\", \"layer3.5.conv1.weight\", \"layer3.5.bn1.weight\", \"layer3.5.bn1.bias\", \"layer3.5.bn1.running_mean\", \"layer3.5.bn1.running_var\", \"layer3.5.bn1.num_batches_tracked\", \"layer3.5.conv2.weight\", \"layer3.5.bn2.weight\", \"layer3.5.bn2.bias\", \"layer3.5.bn2.running_mean\", \"layer3.5.bn2.running_var\", \"layer3.5.bn2.num_batches_tracked\", \"layer3.5.conv3.weight\", \"layer3.5.bn3.weight\", \"layer3.5.bn3.bias\", \"layer3.5.bn3.running_mean\", \"layer3.5.bn3.running_var\", \"layer3.5.bn3.num_batches_tracked\", \"layer4.0.conv1.weight\", \"layer4.0.bn1.weight\", \"layer4.0.bn1.bias\", \"layer4.0.bn1.running_mean\", \"layer4.0.bn1.running_var\", \"layer4.0.bn1.num_batches_tracked\", \"layer4.0.conv2.weight\", \"layer4.0.bn2.weight\", \"layer4.0.bn2.bias\", \"layer4.0.bn2.running_mean\", \"layer4.0.bn2.running_var\", \"layer4.0.bn2.num_batches_tracked\", \"layer4.0.conv3.weight\", \"layer4.0.bn3.weight\", \"layer4.0.bn3.bias\", \"layer4.0.bn3.running_mean\", \"layer4.0.bn3.running_var\", \"layer4.0.bn3.num_batches_tracked\", \"layer4.0.downsample.0.weight\", \"layer4.0.downsample.1.weight\", \"layer4.0.downsample.1.bias\", \"layer4.0.downsample.1.running_mean\", \"layer4.0.downsample.1.running_var\", \"layer4.0.downsample.1.num_batches_tracked\", \"layer4.1.conv1.weight\", \"layer4.1.bn1.weight\", \"layer4.1.bn1.bias\", \"layer4.1.bn1.running_mean\", \"layer4.1.bn1.running_var\", \"layer4.1.bn1.num_batches_tracked\", \"layer4.1.conv2.weight\", \"layer4.1.bn2.weight\", \"layer4.1.bn2.bias\", \"layer4.1.bn2.running_mean\", \"layer4.1.bn2.running_var\", \"layer4.1.bn2.num_batches_tracked\", \"layer4.1.conv3.weight\", \"layer4.1.bn3.weight\", \"layer4.1.bn3.bias\", \"layer4.1.bn3.running_mean\", \"layer4.1.bn3.running_var\", \"layer4.1.bn3.num_batches_tracked\", \"layer4.2.conv1.weight\", \"layer4.2.bn1.weight\", \"layer4.2.bn1.bias\", \"layer4.2.bn1.running_mean\", \"layer4.2.bn1.running_var\", \"layer4.2.bn1.num_batches_tracked\", \"layer4.2.conv2.weight\", \"layer4.2.bn2.weight\", \"layer4.2.bn2.bias\", \"layer4.2.bn2.running_mean\", \"layer4.2.bn2.running_var\", \"layer4.2.bn2.num_batches_tracked\", \"layer4.2.conv3.weight\", \"layer4.2.bn3.weight\", \"layer4.2.bn3.bias\", \"layer4.2.bn3.running_mean\", \"layer4.2.bn3.running_var\", \"layer4.2.bn3.num_batches_tracked\". ",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mRuntimeError\u001b[0m                              Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[37], line 23\u001b[0m\n\u001b[1;32m     12\u001b[0m     objs \u001b[39m=\u001b[39m [\n\u001b[1;32m     13\u001b[0m         {\n\u001b[1;32m     14\u001b[0m             \u001b[39m\"\u001b[39m\u001b[39mengine\u001b[39m\u001b[39m\"\u001b[39m: trainer\u001b[39m.\u001b[39mtrainer,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m     19\u001b[0m         }\n\u001b[1;32m     20\u001b[0m     ]\n\u001b[1;32m     22\u001b[0m \u001b[39mfor\u001b[39;00m to_load \u001b[39min\u001b[39;00m objs:\n\u001b[0;32m---> 23\u001b[0m     checkpoint_fn\u001b[39m.\u001b[39;49mload_best_checkpoint(to_load)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/checkpoint_utils.py:97\u001b[0m, in \u001b[0;36mCheckpointFnCreator.load_best_checkpoint\u001b[0;34m(self, to_load)\u001b[0m\n\u001b[1;32m     95\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mload_best_checkpoint\u001b[39m(\u001b[39mself\u001b[39m, to_load):\n\u001b[1;32m     96\u001b[0m     last_checkpoint \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_best_checkpoint()\n\u001b[0;32m---> 97\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mload_objects(to_load, last_checkpoint)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/checkpoint_utils.py:93\u001b[0m, in \u001b[0;36mCheckpointFnCreator.load_objects\u001b[0;34m(self, to_load, checkpoint, global_step)\u001b[0m\n\u001b[1;32m     89\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mobjs\u001b[39m.\u001b[39mreload_objects(\n\u001b[1;32m     90\u001b[0m         to_load, name\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mcheckpoint\u001b[39m\u001b[39m\"\u001b[39m, global_step\u001b[39m=\u001b[39mglobal_step\n\u001b[1;32m     91\u001b[0m     )\n\u001b[1;32m     92\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 93\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mobjs\u001b[39m.\u001b[39;49mload_objects(to_load, \u001b[39mstr\u001b[39;49m(checkpoint))\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/handlers/checkpoint.py:618\u001b[0m, in \u001b[0;36mCheckpoint.load_objects\u001b[0;34m(to_load, checkpoint, **kwargs)\u001b[0m\n\u001b[1;32m    616\u001b[0m \u001b[39mif\u001b[39;00m k \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m checkpoint_obj:\n\u001b[1;32m    617\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mObject labeled by \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{\u001b[39;00mk\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m from `to_load` is not found in the checkpoint\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m--> 618\u001b[0m _load_object(obj, checkpoint_obj[k])\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/handlers/checkpoint.py:605\u001b[0m, in \u001b[0;36mCheckpoint.load_objects.<locals>._load_object\u001b[0;34m(obj, chkpt_obj)\u001b[0m\n\u001b[1;32m    603\u001b[0m     obj\u001b[39m.\u001b[39mload_state_dict(chkpt_obj, strict\u001b[39m=\u001b[39mis_state_dict_strict)\n\u001b[1;32m    604\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 605\u001b[0m     obj\u001b[39m.\u001b[39;49mload_state_dict(chkpt_obj)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/containers/base_container.py:158\u001b[0m, in \u001b[0;36mBaseContainer.load_state_dict\u001b[0;34m(self, state_dict)\u001b[0m\n\u001b[1;32m    156\u001b[0m c_f\u001b[39m.\u001b[39massert_state_dict_keys(state_dict, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkeys())\n\u001b[1;32m    157\u001b[0m \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m state_dict\u001b[39m.\u001b[39mitems():\n\u001b[0;32m--> 158\u001b[0m     \u001b[39mself\u001b[39;49m[k]\u001b[39m.\u001b[39;49mload_state_dict(v)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/modules/module.py:1223\u001b[0m, in \u001b[0;36mModule.load_state_dict\u001b[0;34m(self, state_dict, strict)\u001b[0m\n\u001b[1;32m   1218\u001b[0m         error_msgs\u001b[39m.\u001b[39minsert(\n\u001b[1;32m   1219\u001b[0m             \u001b[39m0\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mMissing key(s) in state_dict: \u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m. \u001b[39m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mformat(\n\u001b[1;32m   1220\u001b[0m                 \u001b[39m'\u001b[39m\u001b[39m, \u001b[39m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mjoin(\u001b[39m'\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mformat(k) \u001b[39mfor\u001b[39;00m k \u001b[39min\u001b[39;00m missing_keys)))\n\u001b[1;32m   1222\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mlen\u001b[39m(error_msgs) \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m:\n\u001b[0;32m-> 1223\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mRuntimeError\u001b[39;00m(\u001b[39m'\u001b[39m\u001b[39mError(s) in loading state_dict for \u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m:\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\\t\u001b[39;00m\u001b[39m{}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mformat(\n\u001b[1;32m   1224\u001b[0m                        \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m\u001b[39m__class__\u001b[39m\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m, \u001b[39m\"\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\\t\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39mjoin(error_msgs)))\n\u001b[1;32m   1225\u001b[0m \u001b[39mreturn\u001b[39;00m _IncompatibleKeys(missing_keys, unexpected_keys)\n",
      "\u001b[0;31mRuntimeError\u001b[0m: Error(s) in loading state_dict for DataParallel:\n\tMissing key(s) in state_dict: \"module.conv1.weight\", \"module.bn1.weight\", \"module.bn1.bias\", \"module.bn1.running_mean\", \"module.bn1.running_var\", \"module.layer1.0.conv1.weight\", \"module.layer1.0.bn1.weight\", \"module.layer1.0.bn1.bias\", \"module.layer1.0.bn1.running_mean\", \"module.layer1.0.bn1.running_var\", \"module.layer1.0.conv2.weight\", \"module.layer1.0.bn2.weight\", \"module.layer1.0.bn2.bias\", \"module.layer1.0.bn2.running_mean\", \"module.layer1.0.bn2.running_var\", \"module.layer1.0.conv3.weight\", \"module.layer1.0.bn3.weight\", \"module.layer1.0.bn3.bias\", \"module.layer1.0.bn3.running_mean\", \"module.layer1.0.bn3.running_var\", \"module.layer1.0.downsample.0.weight\", \"module.layer1.0.downsample.1.weight\", \"module.layer1.0.downsample.1.bias\", \"module.layer1.0.downsample.1.running_mean\", \"module.layer1.0.downsample.1.running_var\", \"module.layer1.1.conv1.weight\", \"module.layer1.1.bn1.weight\", \"module.layer1.1.bn1.bias\", \"module.layer1.1.bn1.running_mean\", \"module.layer1.1.bn1.running_var\", \"module.layer1.1.conv2.weight\", \"module.layer1.1.bn2.weight\", \"module.layer1.1.bn2.bias\", \"module.layer1.1.bn2.running_mean\", \"module.layer1.1.bn2.running_var\", \"module.layer1.1.conv3.weight\", \"module.layer1.1.bn3.weight\", \"module.layer1.1.bn3.bias\", \"module.layer1.1.bn3.running_mean\", \"module.layer1.1.bn3.running_var\", \"module.layer1.2.conv1.weight\", \"module.layer1.2.bn1.weight\", \"module.layer1.2.bn1.bias\", \"module.layer1.2.bn1.running_mean\", \"module.layer1.2.bn1.running_var\", \"module.layer1.2.conv2.weight\", \"module.layer1.2.bn2.weight\", \"module.layer1.2.bn2.bias\", \"module.layer1.2.bn2.running_mean\", \"module.layer1.2.bn2.running_var\", \"module.layer1.2.conv3.weight\", \"module.layer1.2.bn3.weight\", \"module.layer1.2.bn3.bias\", \"module.layer1.2.bn3.running_mean\", \"module.layer1.2.bn3.running_var\", \"module.layer2.0.conv1.weight\", \"module.layer2.0.bn1.weight\", \"module.layer2.0.bn1.bias\", \"module.layer2.0.bn1.running_mean\", \"module.layer2.0.bn1.running_var\", \"module.layer2.0.conv2.weight\", \"module.layer2.0.bn2.weight\", \"module.layer2.0.bn2.bias\", \"module.layer2.0.bn2.running_mean\", \"module.layer2.0.bn2.running_var\", \"module.layer2.0.conv3.weight\", \"module.layer2.0.bn3.weight\", \"module.layer2.0.bn3.bias\", \"module.layer2.0.bn3.running_mean\", \"module.layer2.0.bn3.running_var\", \"module.layer2.0.downsample.0.weight\", \"module.layer2.0.downsample.1.weight\", \"module.layer2.0.downsample.1.bias\", \"module.layer2.0.downsample.1.running_mean\", \"module.layer2.0.downsample.1.running_var\", \"module.layer2.1.conv1.weight\", \"module.layer2.1.bn1.weight\", \"module.layer2.1.bn1.bias\", \"module.layer2.1.bn1.running_mean\", \"module.layer2.1.bn1.running_var\", \"module.layer2.1.conv2.weight\", \"module.layer2.1.bn2.weight\", \"module.layer2.1.bn2.bias\", \"module.layer2.1.bn2.running_mean\", \"module.layer2.1.bn2.running_var\", \"module.layer2.1.conv3.weight\", \"module.layer2.1.bn3.weight\", \"module.layer2.1.bn3.bias\", \"module.layer2.1.bn3.running_mean\", \"module.layer2.1.bn3.running_var\", \"module.layer2.2.conv1.weight\", \"module.layer2.2.bn1.weight\", \"module.layer2.2.bn1.bias\", \"module.layer2.2.bn1.running_mean\", \"module.layer2.2.bn1.running_var\", \"module.layer2.2.conv2.weight\", \"module.layer2.2.bn2.weight\", \"module.layer2.2.bn2.bias\", \"module.layer2.2.bn2.running_mean\", \"module.layer2.2.bn2.running_var\", \"module.layer2.2.conv3.weight\", \"module.layer2.2.bn3.weight\", \"module.layer2.2.bn3.bias\", \"module.layer2.2.bn3.running_mean\", \"module.layer2.2.bn3.running_var\", \"module.layer2.3.conv1.weight\", \"module.layer2.3.bn1.weight\", \"module.layer2.3.bn1.bias\", \"module.layer2.3.bn1.running_mean\", \"module.layer2.3.bn1.running_var\", \"module.layer2.3.conv2.weight\", \"module.layer2.3.bn2.weight\", \"module.layer2.3.bn2.bias\", \"module.layer2.3.bn2.running_mean\", \"module.layer2.3.bn2.running_var\", \"module.layer2.3.conv3.weight\", \"module.layer2.3.bn3.weight\", \"module.layer2.3.bn3.bias\", \"module.layer2.3.bn3.running_mean\", \"module.layer2.3.bn3.running_var\", \"module.layer3.0.conv1.weight\", \"module.layer3.0.bn1.weight\", \"module.layer3.0.bn1.bias\", \"module.layer3.0.bn1.running_mean\", \"module.layer3.0.bn1.running_var\", \"module.layer3.0.conv2.weight\", \"module.layer3.0.bn2.weight\", \"module.layer3.0.bn2.bias\", \"module.layer3.0.bn2.running_mean\", \"module.layer3.0.bn2.running_var\", \"module.layer3.0.conv3.weight\", \"module.layer3.0.bn3.weight\", \"module.layer3.0.bn3.bias\", \"module.layer3.0.bn3.running_mean\", \"module.layer3.0.bn3.running_var\", \"module.layer3.0.downsample.0.weight\", \"module.layer3.0.downsample.1.weight\", \"module.layer3.0.downsample.1.bias\", \"module.layer3.0.downsample.1.running_mean\", \"module.layer3.0.downsample.1.running_var\", \"module.layer3.1.conv1.weight\", \"module.layer3.1.bn1.weight\", \"module.layer3.1.bn1.bias\", \"module.layer3.1.bn1.running_mean\", \"module.layer3.1.bn1.running_var\", \"module.layer3.1.conv2.weight\", \"module.layer3.1.bn2.weight\", \"module.layer3.1.bn2.bias\", \"module.layer3.1.bn2.running_mean\", \"module.layer3.1.bn2.running_var\", \"module.layer3.1.conv3.weight\", \"module.layer3.1.bn3.weight\", \"module.layer3.1.bn3.bias\", \"module.layer3.1.bn3.running_mean\", \"module.layer3.1.bn3.running_var\", \"module.layer3.2.conv1.weight\", \"module.layer3.2.bn1.weight\", \"module.layer3.2.bn1.bias\", \"module.layer3.2.bn1.running_mean\", \"module.layer3.2.bn1.running_var\", \"module.layer3.2.conv2.weight\", \"module.layer3.2.bn2.weight\", \"module.layer3.2.bn2.bias\", \"module.layer3.2.bn2.running_mean\", \"module.layer3.2.bn2.running_var\", \"module.layer3.2.conv3.weight\", \"module.layer3.2.bn3.weight\", \"module.layer3.2.bn3.bias\", \"module.layer3.2.bn3.running_mean\", \"module.layer3.2.bn3.running_var\", \"module.layer3.3.conv1.weight\", \"module.layer3.3.bn1.weight\", \"module.layer3.3.bn1.bias\", \"module.layer3.3.bn1.running_mean\", \"module.layer3.3.bn1.running_var\", \"module.layer3.3.conv2.weight\", \"module.layer3.3.bn2.weight\", \"module.layer3.3.bn2.bias\", \"module.layer3.3.bn2.running_mean\", \"module.layer3.3.bn2.running_var\", \"module.layer3.3.conv3.weight\", \"module.layer3.3.bn3.weight\", \"module.layer3.3.bn3.bias\", \"module.layer3.3.bn3.running_mean\", \"module.layer3.3.bn3.running_var\", \"module.layer3.4.conv1.weight\", \"module.layer3.4.bn1.weight\", \"module.layer3.4.bn1.bias\", \"module.layer3.4.bn1.running_mean\", \"module.layer3.4.bn1.running_var\", \"module.layer3.4.conv2.weight\", \"module.layer3.4.bn2.weight\", \"module.layer3.4.bn2.bias\", \"module.layer3.4.bn2.running_mean\", \"module.layer3.4.bn2.running_var\", \"module.layer3.4.conv3.weight\", \"module.layer3.4.bn3.weight\", \"module.layer3.4.bn3.bias\", \"module.layer3.4.bn3.running_mean\", \"module.layer3.4.bn3.running_var\", \"module.layer3.5.conv1.weight\", \"module.layer3.5.bn1.weight\", \"module.layer3.5.bn1.bias\", \"module.layer3.5.bn1.running_mean\", \"module.layer3.5.bn1.running_var\", \"module.layer3.5.conv2.weight\", \"module.layer3.5.bn2.weight\", \"module.layer3.5.bn2.bias\", \"module.layer3.5.bn2.running_mean\", \"module.layer3.5.bn2.running_var\", \"module.layer3.5.conv3.weight\", \"module.layer3.5.bn3.weight\", \"module.layer3.5.bn3.bias\", \"module.layer3.5.bn3.running_mean\", \"module.layer3.5.bn3.running_var\", \"module.layer4.0.conv1.weight\", \"module.layer4.0.bn1.weight\", \"module.layer4.0.bn1.bias\", \"module.layer4.0.bn1.running_mean\", \"module.layer4.0.bn1.running_var\", \"module.layer4.0.conv2.weight\", \"module.layer4.0.bn2.weight\", \"module.layer4.0.bn2.bias\", \"module.layer4.0.bn2.running_mean\", \"module.layer4.0.bn2.running_var\", \"module.layer4.0.conv3.weight\", \"module.layer4.0.bn3.weight\", \"module.layer4.0.bn3.bias\", \"module.layer4.0.bn3.running_mean\", \"module.layer4.0.bn3.running_var\", \"module.layer4.0.downsample.0.weight\", \"module.layer4.0.downsample.1.weight\", \"module.layer4.0.downsample.1.bias\", \"module.layer4.0.downsample.1.running_mean\", \"module.layer4.0.downsample.1.running_var\", \"module.layer4.1.conv1.weight\", \"module.layer4.1.bn1.weight\", \"module.layer4.1.bn1.bias\", \"module.layer4.1.bn1.running_mean\", \"module.layer4.1.bn1.running_var\", \"module.layer4.1.conv2.weight\", \"module.layer4.1.bn2.weight\", \"module.layer4.1.bn2.bias\", \"module.layer4.1.bn2.running_mean\", \"module.layer4.1.bn2.running_var\", \"module.layer4.1.conv3.weight\", \"module.layer4.1.bn3.weight\", \"module.layer4.1.bn3.bias\", \"module.layer4.1.bn3.running_mean\", \"module.layer4.1.bn3.running_var\", \"module.layer4.2.conv1.weight\", \"module.layer4.2.bn1.weight\", \"module.layer4.2.bn1.bias\", \"module.layer4.2.bn1.running_mean\", \"module.layer4.2.bn1.running_var\", \"module.layer4.2.conv2.weight\", \"module.layer4.2.bn2.weight\", \"module.layer4.2.bn2.bias\", \"module.layer4.2.bn2.running_mean\", \"module.layer4.2.bn2.running_var\", \"module.layer4.2.conv3.weight\", \"module.layer4.2.bn3.weight\", \"module.layer4.2.bn3.bias\", \"module.layer4.2.bn3.running_mean\", \"module.layer4.2.bn3.running_var\". \n\tUnexpected key(s) in state_dict: \"conv1.weight\", \"bn1.weight\", \"bn1.bias\", \"bn1.running_mean\", \"bn1.running_var\", \"bn1.num_batches_tracked\", \"layer1.0.conv1.weight\", \"layer1.0.bn1.weight\", \"layer1.0.bn1.bias\", \"layer1.0.bn1.running_mean\", \"layer1.0.bn1.running_var\", \"layer1.0.bn1.num_batches_tracked\", \"layer1.0.conv2.weight\", \"layer1.0.bn2.weight\", \"layer1.0.bn2.bias\", \"layer1.0.bn2.running_mean\", \"layer1.0.bn2.running_var\", \"layer1.0.bn2.num_batches_tracked\", \"layer1.0.conv3.weight\", \"layer1.0.bn3.weight\", \"layer1.0.bn3.bias\", \"layer1.0.bn3.running_mean\", \"layer1.0.bn3.running_var\", \"layer1.0.bn3.num_batches_tracked\", \"layer1.0.downsample.0.weight\", \"layer1.0.downsample.1.weight\", \"layer1.0.downsample.1.bias\", \"layer1.0.downsample.1.running_mean\", \"layer1.0.downsample.1.running_var\", \"layer1.0.downsample.1.num_batches_tracked\", \"layer1.1.conv1.weight\", \"layer1.1.bn1.weight\", \"layer1.1.bn1.bias\", \"layer1.1.bn1.running_mean\", \"layer1.1.bn1.running_var\", \"layer1.1.bn1.num_batches_tracked\", \"layer1.1.conv2.weight\", \"layer1.1.bn2.weight\", \"layer1.1.bn2.bias\", \"layer1.1.bn2.running_mean\", \"layer1.1.bn2.running_var\", \"layer1.1.bn2.num_batches_tracked\", \"layer1.1.conv3.weight\", \"layer1.1.bn3.weight\", \"layer1.1.bn3.bias\", \"layer1.1.bn3.running_mean\", \"layer1.1.bn3.running_var\", \"layer1.1.bn3.num_batches_tracked\", \"layer1.2.conv1.weight\", \"layer1.2.bn1.weight\", \"layer1.2.bn1.bias\", \"layer1.2.bn1.running_mean\", \"layer1.2.bn1.running_var\", \"layer1.2.bn1.num_batches_tracked\", \"layer1.2.conv2.weight\", \"layer1.2.bn2.weight\", \"layer1.2.bn2.bias\", \"layer1.2.bn2.running_mean\", \"layer1.2.bn2.running_var\", \"layer1.2.bn2.num_batches_tracked\", \"layer1.2.conv3.weight\", \"layer1.2.bn3.weight\", \"layer1.2.bn3.bias\", \"layer1.2.bn3.running_mean\", \"layer1.2.bn3.running_var\", \"layer1.2.bn3.num_batches_tracked\", \"layer2.0.conv1.weight\", \"layer2.0.bn1.weight\", \"layer2.0.bn1.bias\", \"layer2.0.bn1.running_mean\", \"layer2.0.bn1.running_var\", \"layer2.0.bn1.num_batches_tracked\", \"layer2.0.conv2.weight\", \"layer2.0.bn2.weight\", \"layer2.0.bn2.bias\", \"layer2.0.bn2.running_mean\", \"layer2.0.bn2.running_var\", \"layer2.0.bn2.num_batches_tracked\", \"layer2.0.conv3.weight\", \"layer2.0.bn3.weight\", \"layer2.0.bn3.bias\", \"layer2.0.bn3.running_mean\", \"layer2.0.bn3.running_var\", \"layer2.0.bn3.num_batches_tracked\", \"layer2.0.downsample.0.weight\", \"layer2.0.downsample.1.weight\", \"layer2.0.downsample.1.bias\", \"layer2.0.downsample.1.running_mean\", \"layer2.0.downsample.1.running_var\", \"layer2.0.downsample.1.num_batches_tracked\", \"layer2.1.conv1.weight\", \"layer2.1.bn1.weight\", \"layer2.1.bn1.bias\", \"layer2.1.bn1.running_mean\", \"layer2.1.bn1.running_var\", \"layer2.1.bn1.num_batches_tracked\", \"layer2.1.conv2.weight\", \"layer2.1.bn2.weight\", \"layer2.1.bn2.bias\", \"layer2.1.bn2.running_mean\", \"layer2.1.bn2.running_var\", \"layer2.1.bn2.num_batches_tracked\", \"layer2.1.conv3.weight\", \"layer2.1.bn3.weight\", \"layer2.1.bn3.bias\", \"layer2.1.bn3.running_mean\", \"layer2.1.bn3.running_var\", \"layer2.1.bn3.num_batches_tracked\", \"layer2.2.conv1.weight\", \"layer2.2.bn1.weight\", \"layer2.2.bn1.bias\", \"layer2.2.bn1.running_mean\", \"layer2.2.bn1.running_var\", \"layer2.2.bn1.num_batches_tracked\", \"layer2.2.conv2.weight\", \"layer2.2.bn2.weight\", \"layer2.2.bn2.bias\", \"layer2.2.bn2.running_mean\", \"layer2.2.bn2.running_var\", \"layer2.2.bn2.num_batches_tracked\", \"layer2.2.conv3.weight\", \"layer2.2.bn3.weight\", \"layer2.2.bn3.bias\", \"layer2.2.bn3.running_mean\", \"layer2.2.bn3.running_var\", \"layer2.2.bn3.num_batches_tracked\", \"layer2.3.conv1.weight\", \"layer2.3.bn1.weight\", \"layer2.3.bn1.bias\", \"layer2.3.bn1.running_mean\", \"layer2.3.bn1.running_var\", \"layer2.3.bn1.num_batches_tracked\", \"layer2.3.conv2.weight\", \"layer2.3.bn2.weight\", \"layer2.3.bn2.bias\", \"layer2.3.bn2.running_mean\", \"layer2.3.bn2.running_var\", \"layer2.3.bn2.num_batches_tracked\", \"layer2.3.conv3.weight\", \"layer2.3.bn3.weight\", \"layer2.3.bn3.bias\", \"layer2.3.bn3.running_mean\", \"layer2.3.bn3.running_var\", \"layer2.3.bn3.num_batches_tracked\", \"layer3.0.conv1.weight\", \"layer3.0.bn1.weight\", \"layer3.0.bn1.bias\", \"layer3.0.bn1.running_mean\", \"layer3.0.bn1.running_var\", \"layer3.0.bn1.num_batches_tracked\", \"layer3.0.conv2.weight\", \"layer3.0.bn2.weight\", \"layer3.0.bn2.bias\", \"layer3.0.bn2.running_mean\", \"layer3.0.bn2.running_var\", \"layer3.0.bn2.num_batches_tracked\", \"layer3.0.conv3.weight\", \"layer3.0.bn3.weight\", \"layer3.0.bn3.bias\", \"layer3.0.bn3.running_mean\", \"layer3.0.bn3.running_var\", \"layer3.0.bn3.num_batches_tracked\", \"layer3.0.downsample.0.weight\", \"layer3.0.downsample.1.weight\", \"layer3.0.downsample.1.bias\", \"layer3.0.downsample.1.running_mean\", \"layer3.0.downsample.1.running_var\", \"layer3.0.downsample.1.num_batches_tracked\", \"layer3.1.conv1.weight\", \"layer3.1.bn1.weight\", \"layer3.1.bn1.bias\", \"layer3.1.bn1.running_mean\", \"layer3.1.bn1.running_var\", \"layer3.1.bn1.num_batches_tracked\", \"layer3.1.conv2.weight\", \"layer3.1.bn2.weight\", \"layer3.1.bn2.bias\", \"layer3.1.bn2.running_mean\", \"layer3.1.bn2.running_var\", \"layer3.1.bn2.num_batches_tracked\", \"layer3.1.conv3.weight\", \"layer3.1.bn3.weight\", \"layer3.1.bn3.bias\", \"layer3.1.bn3.running_mean\", \"layer3.1.bn3.running_var\", \"layer3.1.bn3.num_batches_tracked\", \"layer3.2.conv1.weight\", \"layer3.2.bn1.weight\", \"layer3.2.bn1.bias\", \"layer3.2.bn1.running_mean\", \"layer3.2.bn1.running_var\", \"layer3.2.bn1.num_batches_tracked\", \"layer3.2.conv2.weight\", \"layer3.2.bn2.weight\", \"layer3.2.bn2.bias\", \"layer3.2.bn2.running_mean\", \"layer3.2.bn2.running_var\", \"layer3.2.bn2.num_batches_tracked\", \"layer3.2.conv3.weight\", \"layer3.2.bn3.weight\", \"layer3.2.bn3.bias\", \"layer3.2.bn3.running_mean\", \"layer3.2.bn3.running_var\", \"layer3.2.bn3.num_batches_tracked\", \"layer3.3.conv1.weight\", \"layer3.3.bn1.weight\", \"layer3.3.bn1.bias\", \"layer3.3.bn1.running_mean\", \"layer3.3.bn1.running_var\", \"layer3.3.bn1.num_batches_tracked\", \"layer3.3.conv2.weight\", \"layer3.3.bn2.weight\", \"layer3.3.bn2.bias\", \"layer3.3.bn2.running_mean\", \"layer3.3.bn2.running_var\", \"layer3.3.bn2.num_batches_tracked\", \"layer3.3.conv3.weight\", \"layer3.3.bn3.weight\", \"layer3.3.bn3.bias\", \"layer3.3.bn3.running_mean\", \"layer3.3.bn3.running_var\", \"layer3.3.bn3.num_batches_tracked\", \"layer3.4.conv1.weight\", \"layer3.4.bn1.weight\", \"layer3.4.bn1.bias\", \"layer3.4.bn1.running_mean\", \"layer3.4.bn1.running_var\", \"layer3.4.bn1.num_batches_tracked\", \"layer3.4.conv2.weight\", \"layer3.4.bn2.weight\", \"layer3.4.bn2.bias\", \"layer3.4.bn2.running_mean\", \"layer3.4.bn2.running_var\", \"layer3.4.bn2.num_batches_tracked\", \"layer3.4.conv3.weight\", \"layer3.4.bn3.weight\", \"layer3.4.bn3.bias\", \"layer3.4.bn3.running_mean\", \"layer3.4.bn3.running_var\", \"layer3.4.bn3.num_batches_tracked\", \"layer3.5.conv1.weight\", \"layer3.5.bn1.weight\", \"layer3.5.bn1.bias\", \"layer3.5.bn1.running_mean\", \"layer3.5.bn1.running_var\", \"layer3.5.bn1.num_batches_tracked\", \"layer3.5.conv2.weight\", \"layer3.5.bn2.weight\", \"layer3.5.bn2.bias\", \"layer3.5.bn2.running_mean\", \"layer3.5.bn2.running_var\", \"layer3.5.bn2.num_batches_tracked\", \"layer3.5.conv3.weight\", \"layer3.5.bn3.weight\", \"layer3.5.bn3.bias\", \"layer3.5.bn3.running_mean\", \"layer3.5.bn3.running_var\", \"layer3.5.bn3.num_batches_tracked\", \"layer4.0.conv1.weight\", \"layer4.0.bn1.weight\", \"layer4.0.bn1.bias\", \"layer4.0.bn1.running_mean\", \"layer4.0.bn1.running_var\", \"layer4.0.bn1.num_batches_tracked\", \"layer4.0.conv2.weight\", \"layer4.0.bn2.weight\", \"layer4.0.bn2.bias\", \"layer4.0.bn2.running_mean\", \"layer4.0.bn2.running_var\", \"layer4.0.bn2.num_batches_tracked\", \"layer4.0.conv3.weight\", \"layer4.0.bn3.weight\", \"layer4.0.bn3.bias\", \"layer4.0.bn3.running_mean\", \"layer4.0.bn3.running_var\", \"layer4.0.bn3.num_batches_tracked\", \"layer4.0.downsample.0.weight\", \"layer4.0.downsample.1.weight\", \"layer4.0.downsample.1.bias\", \"layer4.0.downsample.1.running_mean\", \"layer4.0.downsample.1.running_var\", \"layer4.0.downsample.1.num_batches_tracked\", \"layer4.1.conv1.weight\", \"layer4.1.bn1.weight\", \"layer4.1.bn1.bias\", \"layer4.1.bn1.running_mean\", \"layer4.1.bn1.running_var\", \"layer4.1.bn1.num_batches_tracked\", \"layer4.1.conv2.weight\", \"layer4.1.bn2.weight\", \"layer4.1.bn2.bias\", \"layer4.1.bn2.running_mean\", \"layer4.1.bn2.running_var\", \"layer4.1.bn2.num_batches_tracked\", \"layer4.1.conv3.weight\", \"layer4.1.bn3.weight\", \"layer4.1.bn3.bias\", \"layer4.1.bn3.running_mean\", \"layer4.1.bn3.running_var\", \"layer4.1.bn3.num_batches_tracked\", \"layer4.2.conv1.weight\", \"layer4.2.bn1.weight\", \"layer4.2.bn1.bias\", \"layer4.2.bn1.running_mean\", \"layer4.2.bn1.running_var\", \"layer4.2.bn1.num_batches_tracked\", \"layer4.2.conv2.weight\", \"layer4.2.bn2.weight\", \"layer4.2.bn2.bias\", \"layer4.2.bn2.running_mean\", \"layer4.2.bn2.running_var\", \"layer4.2.bn2.num_batches_tracked\", \"layer4.2.conv3.weight\", \"layer4.2.bn3.weight\", \"layer4.2.bn3.bias\", \"layer4.2.bn3.running_mean\", \"layer4.2.bn3.running_var\", \"layer4.2.bn3.num_batches_tracked\". "
     ]
    }
   ],
   "source": [
    "\n",
    "load_partial = False\n",
    "\n",
    "if load_partial:\n",
    "    objs = [\n",
    "        {\n",
    "            \"engine\": trainer.trainer,\n",
    "            **checkpoint_utils.adapter_to_dict(trainer.adapter),\n",
    "        },\n",
    "        {\"validator\": validator},\n",
    "    ]\n",
    "else:\n",
    "    objs = [\n",
    "        {\n",
    "            \"engine\": trainer.trainer,\n",
    "            \"validator\": trainer.validator,\n",
    "            \"models\": trainer.adapter.models\n",
    "            # \"adapter\": trainer.adapter,\n",
    "            # **checkpoint_utils.adapter_to_dict(trainer.adapter),\n",
    "        }\n",
    "    ]\n",
    "\n",
    "for to_load in objs:\n",
    "    checkpoint_fn.load_best_checkpoint(to_load)\n",
    "\n",
    "# trainer.adapter.models\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'models': G: DataParallel(\n",
       "   (module): ResNet(\n",
       "     (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)\n",
       "     (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "     (act1): ReLU(inplace=True)\n",
       "     (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n",
       "     (layer1): Sequential(\n",
       "       (0): Bottleneck(\n",
       "         (conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "         (downsample): Sequential(\n",
       "           (0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "           (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         )\n",
       "       )\n",
       "       (1): Bottleneck(\n",
       "         (conv1): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (2): Bottleneck(\n",
       "         (conv1): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "     )\n",
       "     (layer2): Sequential(\n",
       "       (0): Bottleneck(\n",
       "         (conv1): Conv2d(256, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "         (downsample): Sequential(\n",
       "           (0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
       "           (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         )\n",
       "       )\n",
       "       (1): Bottleneck(\n",
       "         (conv1): Conv2d(512, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (2): Bottleneck(\n",
       "         (conv1): Conv2d(512, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (3): Bottleneck(\n",
       "         (conv1): Conv2d(512, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "     )\n",
       "     (layer3): Sequential(\n",
       "       (0): Bottleneck(\n",
       "         (conv1): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "         (downsample): Sequential(\n",
       "           (0): Conv2d(512, 1024, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
       "           (1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         )\n",
       "       )\n",
       "       (1): Bottleneck(\n",
       "         (conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (2): Bottleneck(\n",
       "         (conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (3): Bottleneck(\n",
       "         (conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (4): Bottleneck(\n",
       "         (conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (5): Bottleneck(\n",
       "         (conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "     )\n",
       "     (layer4): Sequential(\n",
       "       (0): Bottleneck(\n",
       "         (conv1): Conv2d(1024, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(512, 2048, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "         (downsample): Sequential(\n",
       "           (0): Conv2d(1024, 2048, kernel_size=(1, 1), stride=(2, 2), bias=False)\n",
       "           (1): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         )\n",
       "       )\n",
       "       (1): Bottleneck(\n",
       "         (conv1): Conv2d(2048, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(512, 2048, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "       (2): Bottleneck(\n",
       "         (conv1): Conv2d(2048, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act1): ReLU(inplace=True)\n",
       "         (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n",
       "         (bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act2): ReLU(inplace=True)\n",
       "         (conv3): Conv2d(512, 2048, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
       "         (bn3): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
       "         (act3): ReLU(inplace=True)\n",
       "       )\n",
       "     )\n",
       "     (global_pool): SelectAdaptivePool2d (pool_type=avg, flatten=True)\n",
       "     (fc): Identity()\n",
       "   )\n",
       " )\n",
       " C: DataParallel(\n",
       "   (module): Classifier(\n",
       "     (net): Sequential(\n",
       "       (0): Linear(in_features=2048, out_features=256, bias=True)\n",
       "       (1): ReLU()\n",
       "       (2): Dropout(p=0.5, inplace=False)\n",
       "       (3): Linear(in_features=256, out_features=128, bias=True)\n",
       "       (4): ReLU()\n",
       "       (5): Dropout(p=0.5, inplace=False)\n",
       "       (6): Linear(in_features=128, out_features=31, bias=True)\n",
       "     )\n",
       "   )\n",
       " ),\n",
       " 'optimizers': G: Adam (\n",
       " Parameter Group 0\n",
       "     amsgrad: False\n",
       "     betas: (0.9, 0.999)\n",
       "     eps: 1e-08\n",
       "     initial_lr: 0.0001\n",
       "     lr: 0.0001\n",
       "     weight_decay: 0\n",
       " )\n",
       " C: Adam (\n",
       " Parameter Group 0\n",
       "     amsgrad: False\n",
       "     betas: (0.9, 0.999)\n",
       "     eps: 1e-08\n",
       "     initial_lr: 0.0001\n",
       "     lr: 0.0001\n",
       "     weight_decay: 0\n",
       " ),\n",
       " 'lr_schedulers': G: <torch.optim.lr_scheduler.ExponentialLR object at 0x7f5960bcdd90>\n",
       " C: <torch.optim.lr_scheduler.ExponentialLR object at 0x7f5960bcdee0>,\n",
       " 'misc': }"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "checkpoint_utils.adapter_to_dict(trainer.adapter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "ename": "RuntimeError",
     "evalue": "Error(s) in loading state_dict for DataParallel:\n\tMissing key(s) in state_dict: \"module.conv1.weight\", \"module.bn1.weight\", \"module.bn1.bias\", \"module.bn1.running_mean\", \"module.bn1.running_var\", \"module.layer1.0.conv1.weight\", \"module.layer1.0.bn1.weight\", \"module.layer1.0.bn1.bias\", \"module.layer1.0.bn1.running_mean\", \"module.layer1.0.bn1.running_var\", \"module.layer1.0.conv2.weight\", \"module.layer1.0.bn2.weight\", \"module.layer1.0.bn2.bias\", \"module.layer1.0.bn2.running_mean\", \"module.layer1.0.bn2.running_var\", \"module.layer1.0.conv3.weight\", \"module.layer1.0.bn3.weight\", \"module.layer1.0.bn3.bias\", \"module.layer1.0.bn3.running_mean\", \"module.layer1.0.bn3.running_var\", \"module.layer1.0.downsample.0.weight\", \"module.layer1.0.downsample.1.weight\", \"module.layer1.0.downsample.1.bias\", \"module.layer1.0.downsample.1.running_mean\", \"module.layer1.0.downsample.1.running_var\", \"module.layer1.1.conv1.weight\", \"module.layer1.1.bn1.weight\", \"module.layer1.1.bn1.bias\", \"module.layer1.1.bn1.running_mean\", \"module.layer1.1.bn1.running_var\", \"module.layer1.1.conv2.weight\", \"module.layer1.1.bn2.weight\", \"module.layer1.1.bn2.bias\", \"module.layer1.1.bn2.running_mean\", \"module.layer1.1.bn2.running_var\", \"module.layer1.1.conv3.weight\", \"module.layer1.1.bn3.weight\", \"module.layer1.1.bn3.bias\", \"module.layer1.1.bn3.running_mean\", \"module.layer1.1.bn3.running_var\", \"module.layer1.2.conv1.weight\", \"module.layer1.2.bn1.weight\", \"module.layer1.2.bn1.bias\", \"module.layer1.2.bn1.running_mean\", \"module.layer1.2.bn1.running_var\", \"module.layer1.2.conv2.weight\", \"module.layer1.2.bn2.weight\", \"module.layer1.2.bn2.bias\", \"module.layer1.2.bn2.running_mean\", \"module.layer1.2.bn2.running_var\", \"module.layer1.2.conv3.weight\", \"module.layer1.2.bn3.weight\", \"module.layer1.2.bn3.bias\", \"module.layer1.2.bn3.running_mean\", \"module.layer1.2.bn3.running_var\", \"module.layer2.0.conv1.weight\", \"module.layer2.0.bn1.weight\", \"module.layer2.0.bn1.bias\", \"module.layer2.0.bn1.running_mean\", \"module.layer2.0.bn1.running_var\", \"module.layer2.0.conv2.weight\", \"module.layer2.0.bn2.weight\", \"module.layer2.0.bn2.bias\", \"module.layer2.0.bn2.running_mean\", \"module.layer2.0.bn2.running_var\", \"module.layer2.0.conv3.weight\", \"module.layer2.0.bn3.weight\", \"module.layer2.0.bn3.bias\", \"module.layer2.0.bn3.running_mean\", \"module.layer2.0.bn3.running_var\", \"module.layer2.0.downsample.0.weight\", \"module.layer2.0.downsample.1.weight\", \"module.layer2.0.downsample.1.bias\", \"module.layer2.0.downsample.1.running_mean\", \"module.layer2.0.downsample.1.running_var\", \"module.layer2.1.conv1.weight\", \"module.layer2.1.bn1.weight\", \"module.layer2.1.bn1.bias\", \"module.layer2.1.bn1.running_mean\", \"module.layer2.1.bn1.running_var\", \"module.layer2.1.conv2.weight\", \"module.layer2.1.bn2.weight\", \"module.layer2.1.bn2.bias\", \"module.layer2.1.bn2.running_mean\", \"module.layer2.1.bn2.running_var\", \"module.layer2.1.conv3.weight\", \"module.layer2.1.bn3.weight\", \"module.layer2.1.bn3.bias\", \"module.layer2.1.bn3.running_mean\", \"module.layer2.1.bn3.running_var\", \"module.layer2.2.conv1.weight\", \"module.layer2.2.bn1.weight\", \"module.layer2.2.bn1.bias\", \"module.layer2.2.bn1.running_mean\", \"module.layer2.2.bn1.running_var\", \"module.layer2.2.conv2.weight\", \"module.layer2.2.bn2.weight\", \"module.layer2.2.bn2.bias\", \"module.layer2.2.bn2.running_mean\", \"module.layer2.2.bn2.running_var\", \"module.layer2.2.conv3.weight\", \"module.layer2.2.bn3.weight\", \"module.layer2.2.bn3.bias\", \"module.layer2.2.bn3.running_mean\", \"module.layer2.2.bn3.running_var\", \"module.layer2.3.conv1.weight\", \"module.layer2.3.bn1.weight\", \"module.layer2.3.bn1.bias\", \"module.layer2.3.bn1.running_mean\", \"module.layer2.3.bn1.running_var\", \"module.layer2.3.conv2.weight\", \"module.layer2.3.bn2.weight\", \"module.layer2.3.bn2.bias\", \"module.layer2.3.bn2.running_mean\", \"module.layer2.3.bn2.running_var\", \"module.layer2.3.conv3.weight\", \"module.layer2.3.bn3.weight\", \"module.layer2.3.bn3.bias\", \"module.layer2.3.bn3.running_mean\", \"module.layer2.3.bn3.running_var\", \"module.layer3.0.conv1.weight\", \"module.layer3.0.bn1.weight\", \"module.layer3.0.bn1.bias\", \"module.layer3.0.bn1.running_mean\", \"module.layer3.0.bn1.running_var\", \"module.layer3.0.conv2.weight\", \"module.layer3.0.bn2.weight\", \"module.layer3.0.bn2.bias\", \"module.layer3.0.bn2.running_mean\", \"module.layer3.0.bn2.running_var\", \"module.layer3.0.conv3.weight\", \"module.layer3.0.bn3.weight\", \"module.layer3.0.bn3.bias\", \"module.layer3.0.bn3.running_mean\", \"module.layer3.0.bn3.running_var\", \"module.layer3.0.downsample.0.weight\", \"module.layer3.0.downsample.1.weight\", \"module.layer3.0.downsample.1.bias\", \"module.layer3.0.downsample.1.running_mean\", \"module.layer3.0.downsample.1.running_var\", \"module.layer3.1.conv1.weight\", \"module.layer3.1.bn1.weight\", \"module.layer3.1.bn1.bias\", \"module.layer3.1.bn1.running_mean\", \"module.layer3.1.bn1.running_var\", \"module.layer3.1.conv2.weight\", \"module.layer3.1.bn2.weight\", \"module.layer3.1.bn2.bias\", \"module.layer3.1.bn2.running_mean\", \"module.layer3.1.bn2.running_var\", \"module.layer3.1.conv3.weight\", \"module.layer3.1.bn3.weight\", \"module.layer3.1.bn3.bias\", \"module.layer3.1.bn3.running_mean\", \"module.layer3.1.bn3.running_var\", \"module.layer3.2.conv1.weight\", \"module.layer3.2.bn1.weight\", \"module.layer3.2.bn1.bias\", \"module.layer3.2.bn1.running_mean\", \"module.layer3.2.bn1.running_var\", \"module.layer3.2.conv2.weight\", \"module.layer3.2.bn2.weight\", \"module.layer3.2.bn2.bias\", \"module.layer3.2.bn2.running_mean\", \"module.layer3.2.bn2.running_var\", \"module.layer3.2.conv3.weight\", \"module.layer3.2.bn3.weight\", \"module.layer3.2.bn3.bias\", \"module.layer3.2.bn3.running_mean\", \"module.layer3.2.bn3.running_var\", \"module.layer3.3.conv1.weight\", \"module.layer3.3.bn1.weight\", \"module.layer3.3.bn1.bias\", \"module.layer3.3.bn1.running_mean\", \"module.layer3.3.bn1.running_var\", \"module.layer3.3.conv2.weight\", \"module.layer3.3.bn2.weight\", \"module.layer3.3.bn2.bias\", \"module.layer3.3.bn2.running_mean\", \"module.layer3.3.bn2.running_var\", \"module.layer3.3.conv3.weight\", \"module.layer3.3.bn3.weight\", \"module.layer3.3.bn3.bias\", \"module.layer3.3.bn3.running_mean\", \"module.layer3.3.bn3.running_var\", \"module.layer3.4.conv1.weight\", \"module.layer3.4.bn1.weight\", \"module.layer3.4.bn1.bias\", \"module.layer3.4.bn1.running_mean\", \"module.layer3.4.bn1.running_var\", \"module.layer3.4.conv2.weight\", \"module.layer3.4.bn2.weight\", \"module.layer3.4.bn2.bias\", \"module.layer3.4.bn2.running_mean\", \"module.layer3.4.bn2.running_var\", \"module.layer3.4.conv3.weight\", \"module.layer3.4.bn3.weight\", \"module.layer3.4.bn3.bias\", \"module.layer3.4.bn3.running_mean\", \"module.layer3.4.bn3.running_var\", \"module.layer3.5.conv1.weight\", \"module.layer3.5.bn1.weight\", \"module.layer3.5.bn1.bias\", \"module.layer3.5.bn1.running_mean\", \"module.layer3.5.bn1.running_var\", \"module.layer3.5.conv2.weight\", \"module.layer3.5.bn2.weight\", \"module.layer3.5.bn2.bias\", \"module.layer3.5.bn2.running_mean\", \"module.layer3.5.bn2.running_var\", \"module.layer3.5.conv3.weight\", \"module.layer3.5.bn3.weight\", \"module.layer3.5.bn3.bias\", \"module.layer3.5.bn3.running_mean\", \"module.layer3.5.bn3.running_var\", \"module.layer4.0.conv1.weight\", \"module.layer4.0.bn1.weight\", \"module.layer4.0.bn1.bias\", \"module.layer4.0.bn1.running_mean\", \"module.layer4.0.bn1.running_var\", \"module.layer4.0.conv2.weight\", \"module.layer4.0.bn2.weight\", \"module.layer4.0.bn2.bias\", \"module.layer4.0.bn2.running_mean\", \"module.layer4.0.bn2.running_var\", \"module.layer4.0.conv3.weight\", \"module.layer4.0.bn3.weight\", \"module.layer4.0.bn3.bias\", \"module.layer4.0.bn3.running_mean\", \"module.layer4.0.bn3.running_var\", \"module.layer4.0.downsample.0.weight\", \"module.layer4.0.downsample.1.weight\", \"module.layer4.0.downsample.1.bias\", \"module.layer4.0.downsample.1.running_mean\", \"module.layer4.0.downsample.1.running_var\", \"module.layer4.1.conv1.weight\", \"module.layer4.1.bn1.weight\", \"module.layer4.1.bn1.bias\", \"module.layer4.1.bn1.running_mean\", \"module.layer4.1.bn1.running_var\", \"module.layer4.1.conv2.weight\", \"module.layer4.1.bn2.weight\", \"module.layer4.1.bn2.bias\", \"module.layer4.1.bn2.running_mean\", \"module.layer4.1.bn2.running_var\", \"module.layer4.1.conv3.weight\", \"module.layer4.1.bn3.weight\", \"module.layer4.1.bn3.bias\", \"module.layer4.1.bn3.running_mean\", \"module.layer4.1.bn3.running_var\", \"module.layer4.2.conv1.weight\", \"module.layer4.2.bn1.weight\", \"module.layer4.2.bn1.bias\", \"module.layer4.2.bn1.running_mean\", \"module.layer4.2.bn1.running_var\", \"module.layer4.2.conv2.weight\", \"module.layer4.2.bn2.weight\", \"module.layer4.2.bn2.bias\", \"module.layer4.2.bn2.running_mean\", \"module.layer4.2.bn2.running_var\", \"module.layer4.2.conv3.weight\", \"module.layer4.2.bn3.weight\", \"module.layer4.2.bn3.bias\", \"module.layer4.2.bn3.running_mean\", \"module.layer4.2.bn3.running_var\". \n\tUnexpected key(s) in state_dict: \"conv1.weight\", \"bn1.weight\", \"bn1.bias\", \"bn1.running_mean\", \"bn1.running_var\", \"bn1.num_batches_tracked\", \"layer1.0.conv1.weight\", \"layer1.0.bn1.weight\", \"layer1.0.bn1.bias\", \"layer1.0.bn1.running_mean\", \"layer1.0.bn1.running_var\", \"layer1.0.bn1.num_batches_tracked\", \"layer1.0.conv2.weight\", \"layer1.0.bn2.weight\", \"layer1.0.bn2.bias\", \"layer1.0.bn2.running_mean\", \"layer1.0.bn2.running_var\", \"layer1.0.bn2.num_batches_tracked\", \"layer1.0.conv3.weight\", \"layer1.0.bn3.weight\", \"layer1.0.bn3.bias\", \"layer1.0.bn3.running_mean\", \"layer1.0.bn3.running_var\", \"layer1.0.bn3.num_batches_tracked\", \"layer1.0.downsample.0.weight\", \"layer1.0.downsample.1.weight\", \"layer1.0.downsample.1.bias\", \"layer1.0.downsample.1.running_mean\", \"layer1.0.downsample.1.running_var\", \"layer1.0.downsample.1.num_batches_tracked\", \"layer1.1.conv1.weight\", \"layer1.1.bn1.weight\", \"layer1.1.bn1.bias\", \"layer1.1.bn1.running_mean\", \"layer1.1.bn1.running_var\", \"layer1.1.bn1.num_batches_tracked\", \"layer1.1.conv2.weight\", \"layer1.1.bn2.weight\", \"layer1.1.bn2.bias\", \"layer1.1.bn2.running_mean\", \"layer1.1.bn2.running_var\", \"layer1.1.bn2.num_batches_tracked\", \"layer1.1.conv3.weight\", \"layer1.1.bn3.weight\", \"layer1.1.bn3.bias\", \"layer1.1.bn3.running_mean\", \"layer1.1.bn3.running_var\", \"layer1.1.bn3.num_batches_tracked\", \"layer1.2.conv1.weight\", \"layer1.2.bn1.weight\", \"layer1.2.bn1.bias\", \"layer1.2.bn1.running_mean\", \"layer1.2.bn1.running_var\", \"layer1.2.bn1.num_batches_tracked\", \"layer1.2.conv2.weight\", \"layer1.2.bn2.weight\", \"layer1.2.bn2.bias\", \"layer1.2.bn2.running_mean\", \"layer1.2.bn2.running_var\", \"layer1.2.bn2.num_batches_tracked\", \"layer1.2.conv3.weight\", \"layer1.2.bn3.weight\", \"layer1.2.bn3.bias\", \"layer1.2.bn3.running_mean\", \"layer1.2.bn3.running_var\", \"layer1.2.bn3.num_batches_tracked\", \"layer2.0.conv1.weight\", \"layer2.0.bn1.weight\", \"layer2.0.bn1.bias\", \"layer2.0.bn1.running_mean\", \"layer2.0.bn1.running_var\", \"layer2.0.bn1.num_batches_tracked\", \"layer2.0.conv2.weight\", \"layer2.0.bn2.weight\", \"layer2.0.bn2.bias\", \"layer2.0.bn2.running_mean\", \"layer2.0.bn2.running_var\", \"layer2.0.bn2.num_batches_tracked\", \"layer2.0.conv3.weight\", \"layer2.0.bn3.weight\", \"layer2.0.bn3.bias\", \"layer2.0.bn3.running_mean\", \"layer2.0.bn3.running_var\", \"layer2.0.bn3.num_batches_tracked\", \"layer2.0.downsample.0.weight\", \"layer2.0.downsample.1.weight\", \"layer2.0.downsample.1.bias\", \"layer2.0.downsample.1.running_mean\", \"layer2.0.downsample.1.running_var\", \"layer2.0.downsample.1.num_batches_tracked\", \"layer2.1.conv1.weight\", \"layer2.1.bn1.weight\", \"layer2.1.bn1.bias\", \"layer2.1.bn1.running_mean\", \"layer2.1.bn1.running_var\", \"layer2.1.bn1.num_batches_tracked\", \"layer2.1.conv2.weight\", \"layer2.1.bn2.weight\", \"layer2.1.bn2.bias\", \"layer2.1.bn2.running_mean\", \"layer2.1.bn2.running_var\", \"layer2.1.bn2.num_batches_tracked\", \"layer2.1.conv3.weight\", \"layer2.1.bn3.weight\", \"layer2.1.bn3.bias\", \"layer2.1.bn3.running_mean\", \"layer2.1.bn3.running_var\", \"layer2.1.bn3.num_batches_tracked\", \"layer2.2.conv1.weight\", \"layer2.2.bn1.weight\", \"layer2.2.bn1.bias\", \"layer2.2.bn1.running_mean\", \"layer2.2.bn1.running_var\", \"layer2.2.bn1.num_batches_tracked\", \"layer2.2.conv2.weight\", \"layer2.2.bn2.weight\", \"layer2.2.bn2.bias\", \"layer2.2.bn2.running_mean\", \"layer2.2.bn2.running_var\", \"layer2.2.bn2.num_batches_tracked\", \"layer2.2.conv3.weight\", \"layer2.2.bn3.weight\", \"layer2.2.bn3.bias\", \"layer2.2.bn3.running_mean\", \"layer2.2.bn3.running_var\", \"layer2.2.bn3.num_batches_tracked\", \"layer2.3.conv1.weight\", \"layer2.3.bn1.weight\", \"layer2.3.bn1.bias\", \"layer2.3.bn1.running_mean\", \"layer2.3.bn1.running_var\", \"layer2.3.bn1.num_batches_tracked\", \"layer2.3.conv2.weight\", \"layer2.3.bn2.weight\", \"layer2.3.bn2.bias\", \"layer2.3.bn2.running_mean\", \"layer2.3.bn2.running_var\", \"layer2.3.bn2.num_batches_tracked\", \"layer2.3.conv3.weight\", \"layer2.3.bn3.weight\", \"layer2.3.bn3.bias\", \"layer2.3.bn3.running_mean\", \"layer2.3.bn3.running_var\", \"layer2.3.bn3.num_batches_tracked\", \"layer3.0.conv1.weight\", \"layer3.0.bn1.weight\", \"layer3.0.bn1.bias\", \"layer3.0.bn1.running_mean\", \"layer3.0.bn1.running_var\", \"layer3.0.bn1.num_batches_tracked\", \"layer3.0.conv2.weight\", \"layer3.0.bn2.weight\", \"layer3.0.bn2.bias\", \"layer3.0.bn2.running_mean\", \"layer3.0.bn2.running_var\", \"layer3.0.bn2.num_batches_tracked\", \"layer3.0.conv3.weight\", \"layer3.0.bn3.weight\", \"layer3.0.bn3.bias\", \"layer3.0.bn3.running_mean\", \"layer3.0.bn3.running_var\", \"layer3.0.bn3.num_batches_tracked\", \"layer3.0.downsample.0.weight\", \"layer3.0.downsample.1.weight\", \"layer3.0.downsample.1.bias\", \"layer3.0.downsample.1.running_mean\", \"layer3.0.downsample.1.running_var\", \"layer3.0.downsample.1.num_batches_tracked\", \"layer3.1.conv1.weight\", \"layer3.1.bn1.weight\", \"layer3.1.bn1.bias\", \"layer3.1.bn1.running_mean\", \"layer3.1.bn1.running_var\", \"layer3.1.bn1.num_batches_tracked\", \"layer3.1.conv2.weight\", \"layer3.1.bn2.weight\", \"layer3.1.bn2.bias\", \"layer3.1.bn2.running_mean\", \"layer3.1.bn2.running_var\", \"layer3.1.bn2.num_batches_tracked\", \"layer3.1.conv3.weight\", \"layer3.1.bn3.weight\", \"layer3.1.bn3.bias\", \"layer3.1.bn3.running_mean\", \"layer3.1.bn3.running_var\", \"layer3.1.bn3.num_batches_tracked\", \"layer3.2.conv1.weight\", \"layer3.2.bn1.weight\", \"layer3.2.bn1.bias\", \"layer3.2.bn1.running_mean\", \"layer3.2.bn1.running_var\", \"layer3.2.bn1.num_batches_tracked\", \"layer3.2.conv2.weight\", \"layer3.2.bn2.weight\", \"layer3.2.bn2.bias\", \"layer3.2.bn2.running_mean\", \"layer3.2.bn2.running_var\", \"layer3.2.bn2.num_batches_tracked\", \"layer3.2.conv3.weight\", \"layer3.2.bn3.weight\", \"layer3.2.bn3.bias\", \"layer3.2.bn3.running_mean\", \"layer3.2.bn3.running_var\", \"layer3.2.bn3.num_batches_tracked\", \"layer3.3.conv1.weight\", \"layer3.3.bn1.weight\", \"layer3.3.bn1.bias\", \"layer3.3.bn1.running_mean\", \"layer3.3.bn1.running_var\", \"layer3.3.bn1.num_batches_tracked\", \"layer3.3.conv2.weight\", \"layer3.3.bn2.weight\", \"layer3.3.bn2.bias\", \"layer3.3.bn2.running_mean\", \"layer3.3.bn2.running_var\", \"layer3.3.bn2.num_batches_tracked\", \"layer3.3.conv3.weight\", \"layer3.3.bn3.weight\", \"layer3.3.bn3.bias\", \"layer3.3.bn3.running_mean\", \"layer3.3.bn3.running_var\", \"layer3.3.bn3.num_batches_tracked\", \"layer3.4.conv1.weight\", \"layer3.4.bn1.weight\", \"layer3.4.bn1.bias\", \"layer3.4.bn1.running_mean\", \"layer3.4.bn1.running_var\", \"layer3.4.bn1.num_batches_tracked\", \"layer3.4.conv2.weight\", \"layer3.4.bn2.weight\", \"layer3.4.bn2.bias\", \"layer3.4.bn2.running_mean\", \"layer3.4.bn2.running_var\", \"layer3.4.bn2.num_batches_tracked\", \"layer3.4.conv3.weight\", \"layer3.4.bn3.weight\", \"layer3.4.bn3.bias\", \"layer3.4.bn3.running_mean\", \"layer3.4.bn3.running_var\", \"layer3.4.bn3.num_batches_tracked\", \"layer3.5.conv1.weight\", \"layer3.5.bn1.weight\", \"layer3.5.bn1.bias\", \"layer3.5.bn1.running_mean\", \"layer3.5.bn1.running_var\", \"layer3.5.bn1.num_batches_tracked\", \"layer3.5.conv2.weight\", \"layer3.5.bn2.weight\", \"layer3.5.bn2.bias\", \"layer3.5.bn2.running_mean\", \"layer3.5.bn2.running_var\", \"layer3.5.bn2.num_batches_tracked\", \"layer3.5.conv3.weight\", \"layer3.5.bn3.weight\", \"layer3.5.bn3.bias\", \"layer3.5.bn3.running_mean\", \"layer3.5.bn3.running_var\", \"layer3.5.bn3.num_batches_tracked\", \"layer4.0.conv1.weight\", \"layer4.0.bn1.weight\", \"layer4.0.bn1.bias\", \"layer4.0.bn1.running_mean\", \"layer4.0.bn1.running_var\", \"layer4.0.bn1.num_batches_tracked\", \"layer4.0.conv2.weight\", \"layer4.0.bn2.weight\", \"layer4.0.bn2.bias\", \"layer4.0.bn2.running_mean\", \"layer4.0.bn2.running_var\", \"layer4.0.bn2.num_batches_tracked\", \"layer4.0.conv3.weight\", \"layer4.0.bn3.weight\", \"layer4.0.bn3.bias\", \"layer4.0.bn3.running_mean\", \"layer4.0.bn3.running_var\", \"layer4.0.bn3.num_batches_tracked\", \"layer4.0.downsample.0.weight\", \"layer4.0.downsample.1.weight\", \"layer4.0.downsample.1.bias\", \"layer4.0.downsample.1.running_mean\", \"layer4.0.downsample.1.running_var\", \"layer4.0.downsample.1.num_batches_tracked\", \"layer4.1.conv1.weight\", \"layer4.1.bn1.weight\", \"layer4.1.bn1.bias\", \"layer4.1.bn1.running_mean\", \"layer4.1.bn1.running_var\", \"layer4.1.bn1.num_batches_tracked\", \"layer4.1.conv2.weight\", \"layer4.1.bn2.weight\", \"layer4.1.bn2.bias\", \"layer4.1.bn2.running_mean\", \"layer4.1.bn2.running_var\", \"layer4.1.bn2.num_batches_tracked\", \"layer4.1.conv3.weight\", \"layer4.1.bn3.weight\", \"layer4.1.bn3.bias\", \"layer4.1.bn3.running_mean\", \"layer4.1.bn3.running_var\", \"layer4.1.bn3.num_batches_tracked\", \"layer4.2.conv1.weight\", \"layer4.2.bn1.weight\", \"layer4.2.bn1.bias\", \"layer4.2.bn1.running_mean\", \"layer4.2.bn1.running_var\", \"layer4.2.bn1.num_batches_tracked\", \"layer4.2.conv2.weight\", \"layer4.2.bn2.weight\", \"layer4.2.bn2.bias\", \"layer4.2.bn2.running_mean\", \"layer4.2.bn2.running_var\", \"layer4.2.bn2.num_batches_tracked\", \"layer4.2.conv3.weight\", \"layer4.2.bn3.weight\", \"layer4.2.bn3.bias\", \"layer4.2.bn3.running_mean\", \"layer4.2.bn3.running_var\", \"layer4.2.bn3.num_batches_tracked\". ",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mRuntimeError\u001b[0m                              Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[19], line 2\u001b[0m\n\u001b[1;32m      1\u001b[0m validator \u001b[39m=\u001b[39m AccuracyValidator(key_map\u001b[39m=\u001b[39m{\u001b[39m\"\u001b[39m\u001b[39mtarget_val_with_labels\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39m\"\u001b[39m\u001b[39msrc_val\u001b[39m\u001b[39m\"\u001b[39m})\n\u001b[0;32m----> 2\u001b[0m score \u001b[39m=\u001b[39m trainer\u001b[39m.\u001b[39;49mevaluate_best_model(datasets, validator, dc)\n\u001b[1;32m      3\u001b[0m \u001b[39mprint\u001b[39m(score)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/ignite.py:323\u001b[0m, in \u001b[0;36mIgnite.evaluate_best_model\u001b[0;34m(self, datasets, validator, dataloader_creator)\u001b[0m\n\u001b[1;32m    321\u001b[0m dataloader_creator \u001b[39m=\u001b[39m c_f\u001b[39m.\u001b[39mdefault(dataloader_creator, DataloaderCreator, {})\n\u001b[1;32m    322\u001b[0m dataloaders \u001b[39m=\u001b[39m dataloader_creator(\u001b[39m*\u001b[39m\u001b[39m*\u001b[39mdatasets)\n\u001b[0;32m--> 323\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcheckpoint_fn\u001b[39m.\u001b[39;49mload_best_checkpoint({\u001b[39m\"\u001b[39;49m\u001b[39mmodels\u001b[39;49m\u001b[39m\"\u001b[39;49m: \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49madapter\u001b[39m.\u001b[39;49mmodels})\n\u001b[1;32m    324\u001b[0m collected_data \u001b[39m=\u001b[39m i_g\u001b[39m.\u001b[39mcollect_from_dataloaders(\n\u001b[1;32m    325\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcollector, dataloaders, validator\u001b[39m.\u001b[39mrequired_data\n\u001b[1;32m    326\u001b[0m )\n\u001b[1;32m    327\u001b[0m \u001b[39mreturn\u001b[39;00m val_utils\u001b[39m.\u001b[39mcall_val_hook(validator, collected_data)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/checkpoint_utils.py:97\u001b[0m, in \u001b[0;36mCheckpointFnCreator.load_best_checkpoint\u001b[0;34m(self, to_load)\u001b[0m\n\u001b[1;32m     95\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mload_best_checkpoint\u001b[39m(\u001b[39mself\u001b[39m, to_load):\n\u001b[1;32m     96\u001b[0m     last_checkpoint \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_best_checkpoint()\n\u001b[0;32m---> 97\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mload_objects(to_load, last_checkpoint)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/frameworks/ignite/checkpoint_utils.py:93\u001b[0m, in \u001b[0;36mCheckpointFnCreator.load_objects\u001b[0;34m(self, to_load, checkpoint, global_step)\u001b[0m\n\u001b[1;32m     89\u001b[0m     \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mobjs\u001b[39m.\u001b[39mreload_objects(\n\u001b[1;32m     90\u001b[0m         to_load, name\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mcheckpoint\u001b[39m\u001b[39m\"\u001b[39m, global_step\u001b[39m=\u001b[39mglobal_step\n\u001b[1;32m     91\u001b[0m     )\n\u001b[1;32m     92\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 93\u001b[0m     \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mobjs\u001b[39m.\u001b[39;49mload_objects(to_load, \u001b[39mstr\u001b[39;49m(checkpoint))\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/handlers/checkpoint.py:618\u001b[0m, in \u001b[0;36mCheckpoint.load_objects\u001b[0;34m(to_load, checkpoint, **kwargs)\u001b[0m\n\u001b[1;32m    616\u001b[0m \u001b[39mif\u001b[39;00m k \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m checkpoint_obj:\n\u001b[1;32m    617\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mObject labeled by \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{\u001b[39;00mk\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m from `to_load` is not found in the checkpoint\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m--> 618\u001b[0m _load_object(obj, checkpoint_obj[k])\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/ignite/handlers/checkpoint.py:605\u001b[0m, in \u001b[0;36mCheckpoint.load_objects.<locals>._load_object\u001b[0;34m(obj, chkpt_obj)\u001b[0m\n\u001b[1;32m    603\u001b[0m     obj\u001b[39m.\u001b[39mload_state_dict(chkpt_obj, strict\u001b[39m=\u001b[39mis_state_dict_strict)\n\u001b[1;32m    604\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 605\u001b[0m     obj\u001b[39m.\u001b[39;49mload_state_dict(chkpt_obj)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/pytorch_adapt/containers/base_container.py:158\u001b[0m, in \u001b[0;36mBaseContainer.load_state_dict\u001b[0;34m(self, state_dict)\u001b[0m\n\u001b[1;32m    156\u001b[0m c_f\u001b[39m.\u001b[39massert_state_dict_keys(state_dict, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkeys())\n\u001b[1;32m    157\u001b[0m \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m state_dict\u001b[39m.\u001b[39mitems():\n\u001b[0;32m--> 158\u001b[0m     \u001b[39mself\u001b[39;49m[k]\u001b[39m.\u001b[39;49mload_state_dict(v)\n",
      "File \u001b[0;32m/media/10TB71/shashemi/miniconda3/envs/cdtrans/lib/python3.8/site-packages/torch/nn/modules/module.py:1223\u001b[0m, in \u001b[0;36mModule.load_state_dict\u001b[0;34m(self, state_dict, strict)\u001b[0m\n\u001b[1;32m   1218\u001b[0m         error_msgs\u001b[39m.\u001b[39minsert(\n\u001b[1;32m   1219\u001b[0m             \u001b[39m0\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mMissing key(s) in state_dict: \u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m. \u001b[39m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mformat(\n\u001b[1;32m   1220\u001b[0m                 \u001b[39m'\u001b[39m\u001b[39m, \u001b[39m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mjoin(\u001b[39m'\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mformat(k) \u001b[39mfor\u001b[39;00m k \u001b[39min\u001b[39;00m missing_keys)))\n\u001b[1;32m   1222\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mlen\u001b[39m(error_msgs) \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m:\n\u001b[0;32m-> 1223\u001b[0m     \u001b[39mraise\u001b[39;00m \u001b[39mRuntimeError\u001b[39;00m(\u001b[39m'\u001b[39m\u001b[39mError(s) in loading state_dict for \u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m:\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\\t\u001b[39;00m\u001b[39m{}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m.\u001b[39mformat(\n\u001b[1;32m   1224\u001b[0m                        \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m\u001b[39m__class__\u001b[39m\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m, \u001b[39m\"\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m\\t\u001b[39;00m\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39mjoin(error_msgs)))\n\u001b[1;32m   1225\u001b[0m \u001b[39mreturn\u001b[39;00m _IncompatibleKeys(missing_keys, unexpected_keys)\n",
      "\u001b[0;31mRuntimeError\u001b[0m: Error(s) in loading state_dict for DataParallel:\n\tMissing key(s) in state_dict: \"module.conv1.weight\", \"module.bn1.weight\", \"module.bn1.bias\", \"module.bn1.running_mean\", \"module.bn1.running_var\", \"module.layer1.0.conv1.weight\", \"module.layer1.0.bn1.weight\", \"module.layer1.0.bn1.bias\", \"module.layer1.0.bn1.running_mean\", \"module.layer1.0.bn1.running_var\", \"module.layer1.0.conv2.weight\", \"module.layer1.0.bn2.weight\", \"module.layer1.0.bn2.bias\", \"module.layer1.0.bn2.running_mean\", \"module.layer1.0.bn2.running_var\", \"module.layer1.0.conv3.weight\", \"module.layer1.0.bn3.weight\", \"module.layer1.0.bn3.bias\", \"module.layer1.0.bn3.running_mean\", \"module.layer1.0.bn3.running_var\", \"module.layer1.0.downsample.0.weight\", \"module.layer1.0.downsample.1.weight\", \"module.layer1.0.downsample.1.bias\", \"module.layer1.0.downsample.1.running_mean\", \"module.layer1.0.downsample.1.running_var\", \"module.layer1.1.conv1.weight\", \"module.layer1.1.bn1.weight\", \"module.layer1.1.bn1.bias\", \"module.layer1.1.bn1.running_mean\", \"module.layer1.1.bn1.running_var\", \"module.layer1.1.conv2.weight\", \"module.layer1.1.bn2.weight\", \"module.layer1.1.bn2.bias\", \"module.layer1.1.bn2.running_mean\", \"module.layer1.1.bn2.running_var\", \"module.layer1.1.conv3.weight\", \"module.layer1.1.bn3.weight\", \"module.layer1.1.bn3.bias\", \"module.layer1.1.bn3.running_mean\", \"module.layer1.1.bn3.running_var\", \"module.layer1.2.conv1.weight\", \"module.layer1.2.bn1.weight\", \"module.layer1.2.bn1.bias\", \"module.layer1.2.bn1.running_mean\", \"module.layer1.2.bn1.running_var\", \"module.layer1.2.conv2.weight\", \"module.layer1.2.bn2.weight\", \"module.layer1.2.bn2.bias\", \"module.layer1.2.bn2.running_mean\", \"module.layer1.2.bn2.running_var\", \"module.layer1.2.conv3.weight\", \"module.layer1.2.bn3.weight\", \"module.layer1.2.bn3.bias\", \"module.layer1.2.bn3.running_mean\", \"module.layer1.2.bn3.running_var\", \"module.layer2.0.conv1.weight\", \"module.layer2.0.bn1.weight\", \"module.layer2.0.bn1.bias\", \"module.layer2.0.bn1.running_mean\", \"module.layer2.0.bn1.running_var\", \"module.layer2.0.conv2.weight\", \"module.layer2.0.bn2.weight\", \"module.layer2.0.bn2.bias\", \"module.layer2.0.bn2.running_mean\", \"module.layer2.0.bn2.running_var\", \"module.layer2.0.conv3.weight\", \"module.layer2.0.bn3.weight\", \"module.layer2.0.bn3.bias\", \"module.layer2.0.bn3.running_mean\", \"module.layer2.0.bn3.running_var\", \"module.layer2.0.downsample.0.weight\", \"module.layer2.0.downsample.1.weight\", \"module.layer2.0.downsample.1.bias\", \"module.layer2.0.downsample.1.running_mean\", \"module.layer2.0.downsample.1.running_var\", \"module.layer2.1.conv1.weight\", \"module.layer2.1.bn1.weight\", \"module.layer2.1.bn1.bias\", \"module.layer2.1.bn1.running_mean\", \"module.layer2.1.bn1.running_var\", \"module.layer2.1.conv2.weight\", \"module.layer2.1.bn2.weight\", \"module.layer2.1.bn2.bias\", \"module.layer2.1.bn2.running_mean\", \"module.layer2.1.bn2.running_var\", \"module.layer2.1.conv3.weight\", \"module.layer2.1.bn3.weight\", \"module.layer2.1.bn3.bias\", \"module.layer2.1.bn3.running_mean\", \"module.layer2.1.bn3.running_var\", \"module.layer2.2.conv1.weight\", \"module.layer2.2.bn1.weight\", \"module.layer2.2.bn1.bias\", \"module.layer2.2.bn1.running_mean\", \"module.layer2.2.bn1.running_var\", \"module.layer2.2.conv2.weight\", \"module.layer2.2.bn2.weight\", \"module.layer2.2.bn2.bias\", \"module.layer2.2.bn2.running_mean\", \"module.layer2.2.bn2.running_var\", \"module.layer2.2.conv3.weight\", \"module.layer2.2.bn3.weight\", \"module.layer2.2.bn3.bias\", \"module.layer2.2.bn3.running_mean\", \"module.layer2.2.bn3.running_var\", \"module.layer2.3.conv1.weight\", \"module.layer2.3.bn1.weight\", \"module.layer2.3.bn1.bias\", \"module.layer2.3.bn1.running_mean\", \"module.layer2.3.bn1.running_var\", \"module.layer2.3.conv2.weight\", \"module.layer2.3.bn2.weight\", \"module.layer2.3.bn2.bias\", \"module.layer2.3.bn2.running_mean\", \"module.layer2.3.bn2.running_var\", \"module.layer2.3.conv3.weight\", \"module.layer2.3.bn3.weight\", \"module.layer2.3.bn3.bias\", \"module.layer2.3.bn3.running_mean\", \"module.layer2.3.bn3.running_var\", \"module.layer3.0.conv1.weight\", \"module.layer3.0.bn1.weight\", \"module.layer3.0.bn1.bias\", \"module.layer3.0.bn1.running_mean\", \"module.layer3.0.bn1.running_var\", \"module.layer3.0.conv2.weight\", \"module.layer3.0.bn2.weight\", \"module.layer3.0.bn2.bias\", \"module.layer3.0.bn2.running_mean\", \"module.layer3.0.bn2.running_var\", \"module.layer3.0.conv3.weight\", \"module.layer3.0.bn3.weight\", \"module.layer3.0.bn3.bias\", \"module.layer3.0.bn3.running_mean\", \"module.layer3.0.bn3.running_var\", \"module.layer3.0.downsample.0.weight\", \"module.layer3.0.downsample.1.weight\", \"module.layer3.0.downsample.1.bias\", \"module.layer3.0.downsample.1.running_mean\", \"module.layer3.0.downsample.1.running_var\", \"module.layer3.1.conv1.weight\", \"module.layer3.1.bn1.weight\", \"module.layer3.1.bn1.bias\", \"module.layer3.1.bn1.running_mean\", \"module.layer3.1.bn1.running_var\", \"module.layer3.1.conv2.weight\", \"module.layer3.1.bn2.weight\", \"module.layer3.1.bn2.bias\", \"module.layer3.1.bn2.running_mean\", \"module.layer3.1.bn2.running_var\", \"module.layer3.1.conv3.weight\", \"module.layer3.1.bn3.weight\", \"module.layer3.1.bn3.bias\", \"module.layer3.1.bn3.running_mean\", \"module.layer3.1.bn3.running_var\", \"module.layer3.2.conv1.weight\", \"module.layer3.2.bn1.weight\", \"module.layer3.2.bn1.bias\", \"module.layer3.2.bn1.running_mean\", \"module.layer3.2.bn1.running_var\", \"module.layer3.2.conv2.weight\", \"module.layer3.2.bn2.weight\", \"module.layer3.2.bn2.bias\", \"module.layer3.2.bn2.running_mean\", \"module.layer3.2.bn2.running_var\", \"module.layer3.2.conv3.weight\", \"module.layer3.2.bn3.weight\", \"module.layer3.2.bn3.bias\", \"module.layer3.2.bn3.running_mean\", \"module.layer3.2.bn3.running_var\", \"module.layer3.3.conv1.weight\", \"module.layer3.3.bn1.weight\", \"module.layer3.3.bn1.bias\", \"module.layer3.3.bn1.running_mean\", \"module.layer3.3.bn1.running_var\", \"module.layer3.3.conv2.weight\", \"module.layer3.3.bn2.weight\", \"module.layer3.3.bn2.bias\", \"module.layer3.3.bn2.running_mean\", \"module.layer3.3.bn2.running_var\", \"module.layer3.3.conv3.weight\", \"module.layer3.3.bn3.weight\", \"module.layer3.3.bn3.bias\", \"module.layer3.3.bn3.running_mean\", \"module.layer3.3.bn3.running_var\", \"module.layer3.4.conv1.weight\", \"module.layer3.4.bn1.weight\", \"module.layer3.4.bn1.bias\", \"module.layer3.4.bn1.running_mean\", \"module.layer3.4.bn1.running_var\", \"module.layer3.4.conv2.weight\", \"module.layer3.4.bn2.weight\", \"module.layer3.4.bn2.bias\", \"module.layer3.4.bn2.running_mean\", \"module.layer3.4.bn2.running_var\", \"module.layer3.4.conv3.weight\", \"module.layer3.4.bn3.weight\", \"module.layer3.4.bn3.bias\", \"module.layer3.4.bn3.running_mean\", \"module.layer3.4.bn3.running_var\", \"module.layer3.5.conv1.weight\", \"module.layer3.5.bn1.weight\", \"module.layer3.5.bn1.bias\", \"module.layer3.5.bn1.running_mean\", \"module.layer3.5.bn1.running_var\", \"module.layer3.5.conv2.weight\", \"module.layer3.5.bn2.weight\", \"module.layer3.5.bn2.bias\", \"module.layer3.5.bn2.running_mean\", \"module.layer3.5.bn2.running_var\", \"module.layer3.5.conv3.weight\", \"module.layer3.5.bn3.weight\", \"module.layer3.5.bn3.bias\", \"module.layer3.5.bn3.running_mean\", \"module.layer3.5.bn3.running_var\", \"module.layer4.0.conv1.weight\", \"module.layer4.0.bn1.weight\", \"module.layer4.0.bn1.bias\", \"module.layer4.0.bn1.running_mean\", \"module.layer4.0.bn1.running_var\", \"module.layer4.0.conv2.weight\", \"module.layer4.0.bn2.weight\", \"module.layer4.0.bn2.bias\", \"module.layer4.0.bn2.running_mean\", \"module.layer4.0.bn2.running_var\", \"module.layer4.0.conv3.weight\", \"module.layer4.0.bn3.weight\", \"module.layer4.0.bn3.bias\", \"module.layer4.0.bn3.running_mean\", \"module.layer4.0.bn3.running_var\", \"module.layer4.0.downsample.0.weight\", \"module.layer4.0.downsample.1.weight\", \"module.layer4.0.downsample.1.bias\", \"module.layer4.0.downsample.1.running_mean\", \"module.layer4.0.downsample.1.running_var\", \"module.layer4.1.conv1.weight\", \"module.layer4.1.bn1.weight\", \"module.layer4.1.bn1.bias\", \"module.layer4.1.bn1.running_mean\", \"module.layer4.1.bn1.running_var\", \"module.layer4.1.conv2.weight\", \"module.layer4.1.bn2.weight\", \"module.layer4.1.bn2.bias\", \"module.layer4.1.bn2.running_mean\", \"module.layer4.1.bn2.running_var\", \"module.layer4.1.conv3.weight\", \"module.layer4.1.bn3.weight\", \"module.layer4.1.bn3.bias\", \"module.layer4.1.bn3.running_mean\", \"module.layer4.1.bn3.running_var\", \"module.layer4.2.conv1.weight\", \"module.layer4.2.bn1.weight\", \"module.layer4.2.bn1.bias\", \"module.layer4.2.bn1.running_mean\", \"module.layer4.2.bn1.running_var\", \"module.layer4.2.conv2.weight\", \"module.layer4.2.bn2.weight\", \"module.layer4.2.bn2.bias\", \"module.layer4.2.bn2.running_mean\", \"module.layer4.2.bn2.running_var\", \"module.layer4.2.conv3.weight\", \"module.layer4.2.bn3.weight\", \"module.layer4.2.bn3.bias\", \"module.layer4.2.bn3.running_mean\", \"module.layer4.2.bn3.running_var\". \n\tUnexpected key(s) in state_dict: \"conv1.weight\", \"bn1.weight\", \"bn1.bias\", \"bn1.running_mean\", \"bn1.running_var\", \"bn1.num_batches_tracked\", \"layer1.0.conv1.weight\", \"layer1.0.bn1.weight\", \"layer1.0.bn1.bias\", \"layer1.0.bn1.running_mean\", \"layer1.0.bn1.running_var\", \"layer1.0.bn1.num_batches_tracked\", \"layer1.0.conv2.weight\", \"layer1.0.bn2.weight\", \"layer1.0.bn2.bias\", \"layer1.0.bn2.running_mean\", \"layer1.0.bn2.running_var\", \"layer1.0.bn2.num_batches_tracked\", \"layer1.0.conv3.weight\", \"layer1.0.bn3.weight\", \"layer1.0.bn3.bias\", \"layer1.0.bn3.running_mean\", \"layer1.0.bn3.running_var\", \"layer1.0.bn3.num_batches_tracked\", \"layer1.0.downsample.0.weight\", \"layer1.0.downsample.1.weight\", \"layer1.0.downsample.1.bias\", \"layer1.0.downsample.1.running_mean\", \"layer1.0.downsample.1.running_var\", \"layer1.0.downsample.1.num_batches_tracked\", \"layer1.1.conv1.weight\", \"layer1.1.bn1.weight\", \"layer1.1.bn1.bias\", \"layer1.1.bn1.running_mean\", \"layer1.1.bn1.running_var\", \"layer1.1.bn1.num_batches_tracked\", \"layer1.1.conv2.weight\", \"layer1.1.bn2.weight\", \"layer1.1.bn2.bias\", \"layer1.1.bn2.running_mean\", \"layer1.1.bn2.running_var\", \"layer1.1.bn2.num_batches_tracked\", \"layer1.1.conv3.weight\", \"layer1.1.bn3.weight\", \"layer1.1.bn3.bias\", \"layer1.1.bn3.running_mean\", \"layer1.1.bn3.running_var\", \"layer1.1.bn3.num_batches_tracked\", \"layer1.2.conv1.weight\", \"layer1.2.bn1.weight\", \"layer1.2.bn1.bias\", \"layer1.2.bn1.running_mean\", \"layer1.2.bn1.running_var\", \"layer1.2.bn1.num_batches_tracked\", \"layer1.2.conv2.weight\", \"layer1.2.bn2.weight\", \"layer1.2.bn2.bias\", \"layer1.2.bn2.running_mean\", \"layer1.2.bn2.running_var\", \"layer1.2.bn2.num_batches_tracked\", \"layer1.2.conv3.weight\", \"layer1.2.bn3.weight\", \"layer1.2.bn3.bias\", \"layer1.2.bn3.running_mean\", \"layer1.2.bn3.running_var\", \"layer1.2.bn3.num_batches_tracked\", \"layer2.0.conv1.weight\", \"layer2.0.bn1.weight\", \"layer2.0.bn1.bias\", \"layer2.0.bn1.running_mean\", \"layer2.0.bn1.running_var\", \"layer2.0.bn1.num_batches_tracked\", \"layer2.0.conv2.weight\", \"layer2.0.bn2.weight\", \"layer2.0.bn2.bias\", \"layer2.0.bn2.running_mean\", \"layer2.0.bn2.running_var\", \"layer2.0.bn2.num_batches_tracked\", \"layer2.0.conv3.weight\", \"layer2.0.bn3.weight\", \"layer2.0.bn3.bias\", \"layer2.0.bn3.running_mean\", \"layer2.0.bn3.running_var\", \"layer2.0.bn3.num_batches_tracked\", \"layer2.0.downsample.0.weight\", \"layer2.0.downsample.1.weight\", \"layer2.0.downsample.1.bias\", \"layer2.0.downsample.1.running_mean\", \"layer2.0.downsample.1.running_var\", \"layer2.0.downsample.1.num_batches_tracked\", \"layer2.1.conv1.weight\", \"layer2.1.bn1.weight\", \"layer2.1.bn1.bias\", \"layer2.1.bn1.running_mean\", \"layer2.1.bn1.running_var\", \"layer2.1.bn1.num_batches_tracked\", \"layer2.1.conv2.weight\", \"layer2.1.bn2.weight\", \"layer2.1.bn2.bias\", \"layer2.1.bn2.running_mean\", \"layer2.1.bn2.running_var\", \"layer2.1.bn2.num_batches_tracked\", \"layer2.1.conv3.weight\", \"layer2.1.bn3.weight\", \"layer2.1.bn3.bias\", \"layer2.1.bn3.running_mean\", \"layer2.1.bn3.running_var\", \"layer2.1.bn3.num_batches_tracked\", \"layer2.2.conv1.weight\", \"layer2.2.bn1.weight\", \"layer2.2.bn1.bias\", \"layer2.2.bn1.running_mean\", \"layer2.2.bn1.running_var\", \"layer2.2.bn1.num_batches_tracked\", \"layer2.2.conv2.weight\", \"layer2.2.bn2.weight\", \"layer2.2.bn2.bias\", \"layer2.2.bn2.running_mean\", \"layer2.2.bn2.running_var\", \"layer2.2.bn2.num_batches_tracked\", \"layer2.2.conv3.weight\", \"layer2.2.bn3.weight\", \"layer2.2.bn3.bias\", \"layer2.2.bn3.running_mean\", \"layer2.2.bn3.running_var\", \"layer2.2.bn3.num_batches_tracked\", \"layer2.3.conv1.weight\", \"layer2.3.bn1.weight\", \"layer2.3.bn1.bias\", \"layer2.3.bn1.running_mean\", \"layer2.3.bn1.running_var\", \"layer2.3.bn1.num_batches_tracked\", \"layer2.3.conv2.weight\", \"layer2.3.bn2.weight\", \"layer2.3.bn2.bias\", \"layer2.3.bn2.running_mean\", \"layer2.3.bn2.running_var\", \"layer2.3.bn2.num_batches_tracked\", \"layer2.3.conv3.weight\", \"layer2.3.bn3.weight\", \"layer2.3.bn3.bias\", \"layer2.3.bn3.running_mean\", \"layer2.3.bn3.running_var\", \"layer2.3.bn3.num_batches_tracked\", \"layer3.0.conv1.weight\", \"layer3.0.bn1.weight\", \"layer3.0.bn1.bias\", \"layer3.0.bn1.running_mean\", \"layer3.0.bn1.running_var\", \"layer3.0.bn1.num_batches_tracked\", \"layer3.0.conv2.weight\", \"layer3.0.bn2.weight\", \"layer3.0.bn2.bias\", \"layer3.0.bn2.running_mean\", \"layer3.0.bn2.running_var\", \"layer3.0.bn2.num_batches_tracked\", \"layer3.0.conv3.weight\", \"layer3.0.bn3.weight\", \"layer3.0.bn3.bias\", \"layer3.0.bn3.running_mean\", \"layer3.0.bn3.running_var\", \"layer3.0.bn3.num_batches_tracked\", \"layer3.0.downsample.0.weight\", \"layer3.0.downsample.1.weight\", \"layer3.0.downsample.1.bias\", \"layer3.0.downsample.1.running_mean\", \"layer3.0.downsample.1.running_var\", \"layer3.0.downsample.1.num_batches_tracked\", \"layer3.1.conv1.weight\", \"layer3.1.bn1.weight\", \"layer3.1.bn1.bias\", \"layer3.1.bn1.running_mean\", \"layer3.1.bn1.running_var\", \"layer3.1.bn1.num_batches_tracked\", \"layer3.1.conv2.weight\", \"layer3.1.bn2.weight\", \"layer3.1.bn2.bias\", \"layer3.1.bn2.running_mean\", \"layer3.1.bn2.running_var\", \"layer3.1.bn2.num_batches_tracked\", \"layer3.1.conv3.weight\", \"layer3.1.bn3.weight\", \"layer3.1.bn3.bias\", \"layer3.1.bn3.running_mean\", \"layer3.1.bn3.running_var\", \"layer3.1.bn3.num_batches_tracked\", \"layer3.2.conv1.weight\", \"layer3.2.bn1.weight\", \"layer3.2.bn1.bias\", \"layer3.2.bn1.running_mean\", \"layer3.2.bn1.running_var\", \"layer3.2.bn1.num_batches_tracked\", \"layer3.2.conv2.weight\", \"layer3.2.bn2.weight\", \"layer3.2.bn2.bias\", \"layer3.2.bn2.running_mean\", \"layer3.2.bn2.running_var\", \"layer3.2.bn2.num_batches_tracked\", \"layer3.2.conv3.weight\", \"layer3.2.bn3.weight\", \"layer3.2.bn3.bias\", \"layer3.2.bn3.running_mean\", \"layer3.2.bn3.running_var\", \"layer3.2.bn3.num_batches_tracked\", \"layer3.3.conv1.weight\", \"layer3.3.bn1.weight\", \"layer3.3.bn1.bias\", \"layer3.3.bn1.running_mean\", \"layer3.3.bn1.running_var\", \"layer3.3.bn1.num_batches_tracked\", \"layer3.3.conv2.weight\", \"layer3.3.bn2.weight\", \"layer3.3.bn2.bias\", \"layer3.3.bn2.running_mean\", \"layer3.3.bn2.running_var\", \"layer3.3.bn2.num_batches_tracked\", \"layer3.3.conv3.weight\", \"layer3.3.bn3.weight\", \"layer3.3.bn3.bias\", \"layer3.3.bn3.running_mean\", \"layer3.3.bn3.running_var\", \"layer3.3.bn3.num_batches_tracked\", \"layer3.4.conv1.weight\", \"layer3.4.bn1.weight\", \"layer3.4.bn1.bias\", \"layer3.4.bn1.running_mean\", \"layer3.4.bn1.running_var\", \"layer3.4.bn1.num_batches_tracked\", \"layer3.4.conv2.weight\", \"layer3.4.bn2.weight\", \"layer3.4.bn2.bias\", \"layer3.4.bn2.running_mean\", \"layer3.4.bn2.running_var\", \"layer3.4.bn2.num_batches_tracked\", \"layer3.4.conv3.weight\", \"layer3.4.bn3.weight\", \"layer3.4.bn3.bias\", \"layer3.4.bn3.running_mean\", \"layer3.4.bn3.running_var\", \"layer3.4.bn3.num_batches_tracked\", \"layer3.5.conv1.weight\", \"layer3.5.bn1.weight\", \"layer3.5.bn1.bias\", \"layer3.5.bn1.running_mean\", \"layer3.5.bn1.running_var\", \"layer3.5.bn1.num_batches_tracked\", \"layer3.5.conv2.weight\", \"layer3.5.bn2.weight\", \"layer3.5.bn2.bias\", \"layer3.5.bn2.running_mean\", \"layer3.5.bn2.running_var\", \"layer3.5.bn2.num_batches_tracked\", \"layer3.5.conv3.weight\", \"layer3.5.bn3.weight\", \"layer3.5.bn3.bias\", \"layer3.5.bn3.running_mean\", \"layer3.5.bn3.running_var\", \"layer3.5.bn3.num_batches_tracked\", \"layer4.0.conv1.weight\", \"layer4.0.bn1.weight\", \"layer4.0.bn1.bias\", \"layer4.0.bn1.running_mean\", \"layer4.0.bn1.running_var\", \"layer4.0.bn1.num_batches_tracked\", \"layer4.0.conv2.weight\", \"layer4.0.bn2.weight\", \"layer4.0.bn2.bias\", \"layer4.0.bn2.running_mean\", \"layer4.0.bn2.running_var\", \"layer4.0.bn2.num_batches_tracked\", \"layer4.0.conv3.weight\", \"layer4.0.bn3.weight\", \"layer4.0.bn3.bias\", \"layer4.0.bn3.running_mean\", \"layer4.0.bn3.running_var\", \"layer4.0.bn3.num_batches_tracked\", \"layer4.0.downsample.0.weight\", \"layer4.0.downsample.1.weight\", \"layer4.0.downsample.1.bias\", \"layer4.0.downsample.1.running_mean\", \"layer4.0.downsample.1.running_var\", \"layer4.0.downsample.1.num_batches_tracked\", \"layer4.1.conv1.weight\", \"layer4.1.bn1.weight\", \"layer4.1.bn1.bias\", \"layer4.1.bn1.running_mean\", \"layer4.1.bn1.running_var\", \"layer4.1.bn1.num_batches_tracked\", \"layer4.1.conv2.weight\", \"layer4.1.bn2.weight\", \"layer4.1.bn2.bias\", \"layer4.1.bn2.running_mean\", \"layer4.1.bn2.running_var\", \"layer4.1.bn2.num_batches_tracked\", \"layer4.1.conv3.weight\", \"layer4.1.bn3.weight\", \"layer4.1.bn3.bias\", \"layer4.1.bn3.running_mean\", \"layer4.1.bn3.running_var\", \"layer4.1.bn3.num_batches_tracked\", \"layer4.2.conv1.weight\", \"layer4.2.bn1.weight\", \"layer4.2.bn1.bias\", \"layer4.2.bn1.running_mean\", \"layer4.2.bn1.running_var\", \"layer4.2.bn1.num_batches_tracked\", \"layer4.2.conv2.weight\", \"layer4.2.bn2.weight\", \"layer4.2.bn2.bias\", \"layer4.2.bn2.running_mean\", \"layer4.2.bn2.running_var\", \"layer4.2.bn2.num_batches_tracked\", \"layer4.2.conv3.weight\", \"layer4.2.bn3.weight\", \"layer4.2.bn3.bias\", \"layer4.2.bn3.running_mean\", \"layer4.2.bn3.running_var\", \"layer4.2.bn3.num_batches_tracked\". "
     ]
    }
   ],
   "source": [
    "validator = AccuracyValidator(key_map={\"target_val_with_labels\": \"src_val\"})\n",
    "score = trainer.evaluate_best_model(datasets, validator, dc)\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "__call__() missing 2 required positional arguments: 'engine' and 'to_save'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[32], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m checkpoint_fn\u001b[39m.\u001b[39;49mobjs()\n",
      "\u001b[0;31mTypeError\u001b[0m: __call__() missing 2 required positional arguments: 'engine' and 'to_save'"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "cdtrans",
   "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.8.15"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "959b82c3a41427bdf7d14d4ba7335271e0c50cfcddd70501934b27dcc36968ad"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
