{"id":20495200,"url":"https://github.com/samuelebortolotti/uda","last_synced_at":"2026-06-09T14:31:50.278Z","repository":{"id":77067950,"uuid":"509677109","full_name":"samuelebortolotti/uda","owner":"samuelebortolotti","description":"Repository containing the Unsupervised Domain Adaptation project developed for the Deep Learning course of the master's degree in Computer Science at University of Trento","archived":false,"fork":false,"pushed_at":"2022-09-16T15:05:32.000Z","size":6094,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T18:27:49.982Z","etag":null,"topics":["artificial-neural-networks","deep-domain-confusion","domain-adversarial-neural-networks","domain-separation-networks","medm","object-recognition","python","unsupervised-domain-adaptation"],"latest_commit_sha":null,"homepage":"https://wandb.ai/deep-learning-project/dl-project","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuelebortolotti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-02T06:25:47.000Z","updated_at":"2024-04-24T05:24:41.000Z","dependencies_parsed_at":"2024-02-18T16:31:50.688Z","dependency_job_id":null,"html_url":"https://github.com/samuelebortolotti/uda","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samuelebortolotti/uda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Fuda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Fuda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Fuda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Fuda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelebortolotti","download_url":"https://codeload.github.com/samuelebortolotti/uda/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Fuda/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34112225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-neural-networks","deep-domain-confusion","domain-adversarial-neural-networks","domain-separation-networks","medm","object-recognition","python","unsupervised-domain-adaptation"],"created_at":"2024-11-15T17:44:55.655Z","updated_at":"2026-06-09T14:31:50.247Z","avatar_url":"https://github.com/samuelebortolotti.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UDA\n\n`UDA` is a collection of methods concerning [unsupervised domain adaptation](https://en.wikipedia.org/wiki/Domain_adaptation) techniques, developed for the Deep Learning course of the master's degree program in Computer Science at the University of Trento.\n\nThe dataset employed is the [Adaptiope](https://ieeexplore.ieee.org/document/9423412) unsupervised domain adaptation benchmark, considering only *few classes* and *only two domains* for the sake of simplicity of the project.\n\nTo simplify the task the domains considered are `product` and `real world` whose chosen categories are: *backpack, bookcase, car jack, comb, crown, file cabinet, flat iron, game controller, glasses, helicopter, ice skates, letter tray, monitor, mug, network switch, over-ear headphones, pen, purse, stand mixer and stroller*.\n\nHere we link the wandb [experiments' learning curves](https://wandb.ai/deep-learning-project/dl-project) and the [Jupyter notebook](uda/notebook/notebook.ipynb).\n\n\u003e **Note:** more information can be found in the `report`\n\n## Authors\n\n|  Name    |  Surname   |     Username        |\n| :------: | :--------: | :-----------------: |\n| Samuele  | Bortolotti | `samuelebortolotti `|\n| Luca     | De Menego  | `lucademenego99`    |\n\n## About\n\nThe objective of the repository is to devise, train and evaluate a deep learning framework on an **Unsupervised Domain Adaptation** setting.\n\nThe test dataset on which the proposed methods are tested is the [Adaptiope](https://openaccess.thecvf.com/content/WACV2021/papers/Ringwald_Adaptiope_A_Modern_Benchmark_for_Unsupervised_Domain_Adaptation_WACV_2021_paper.pdf), a large scale, diverse UDA dataset with 3 domains: synthetic, product and real world data.\n\nThe implemented networks will be trained:\n- in a supervised way on the source domain;\n- in an unsupervised way on the target domain.\n\nThe **gain**, namely the amount of improvement we receive when we use the domain adaption framework compared to the outcome we get without any domain alignment approach, is used to assess the quality of the domain alignment strategy. The gain can be represented mathematically as: \n\n$$G = acc_{uda} − acc_{so}$$\n\nThis has been be done in both directions between the two selected domains, using as evaluation metric the **validation accuracy** on the target domain:\n\n$$Accuracy = \\frac{T_P + T_N}{T_P + T_N + F_P + F_N}$$\n\nWhere:\n\n- $TP$ stands for true positives, namely cases in which the algorithm correctly predicted the positive class\n- $TN$ stands for true negatives, namely cases in which the algorithm correctly predicted the negative class\n- $FP$ stands for false positives, namely cases in which samples are associated with the positive class whereas they belong to the negative one. (Also known as a \"Type I error.\")\n- $FN$ stands for false negatives, namely cases in which samples are associated with the negative class whereas they belong to the positive one. (Also known as a \"Type II error.\")\n\nEventually lower and upper bounds will be calculated training the networks only on one specific domain (source domain for alower bound, target domain for an upper bound), enabling us to provide some considerations about the achievements of our architectures.\n\n### Domain Adaptation background\n\nJust to give a formal background, we leverage on the definition of Domain Adaptation provided by [Gabriela Csurka et.al](https://arxiv.org/pdf/1702.05374.pdf) which in the following sub-section will be presented.\n\nWe define a domain $D$ as a d-dimensional feature space $X \\in \\mathcal{R}^d$ based on a marginal probability distribution $P(X)$, and a task $T$ is defined as a conditional probability distribution $P(Y|X)$ where $Y$ is the label space. \n\nGiven sample set $X = \\{x_1, \\cdots x_n\\}$ of $X$ and their corresponding labels $Y = \\{y_1, \\cdots y_n\\}$ from $Y$. \nIn general, these feature-label pairings $\\{x_i, y_i\\}$ may be used in order to learn the probability distribution $P(Y|X)$ in a supervised way.\n\nLet us assume we have two domains with their related tasks: a source domain $D_s = {X_s, P(X_s)}$ with $T_s = {Y_s, P(Y_s|X_s)}$ and a target domain $Dt = {X_t, P(X_t)}$ with $T_t = {Y_t, P(Y_t|X_t)}$. \n\nIf the two domains corresponds, namely $D_s = D_t$ and $T_s = T_t$, traditional machine learning methods can be used to solve the problem, where $D_s$ becomes the training set and $D_t$ the test set.\n\nHowever, this assumption is violated, $D_t \\neq D_s$ or $T_t \\neq T_s$, the models trained on $D_s$ might perform poorly on $D_t$, or they are not applicable directly if $T_t \\neq T_s$. Futhermore, when the source domain is related to the target, it is possible to exploit the related information from $\\{D_s, T_s\\}$ to learn $P(Y_t|X_t)$. This process is known as **transfer learning**.\n\n**Domain Adaptation**, usually refers to problems in which the tasks are considered to be the same ($T_t = T_s$), but the domain is different ($D_s = T_s$).\n\nIn a classification task, both the set of labels and the conditional distributions are assumed to be shared between the two domains, i.e. $Y_s = Y_t$ and $P(Y|X_t) = P(Y|X_s)$. \n\nThe second assumption, $P(Y|X_t) = P(Y|X_s)$, is, however, fairly strong and does not always hold in real-world applications.\nAs a result, the definition of domain adaptation is simplified to simply need the first assumption, namely that $Y_s = Y_t = Y$.\n\nFurthermore, the Domain Adaptation community distinguishes between the unsupervised scenario, in which labels are only accessible for the source domain, and the semi-supervised condition, in which only a limited number of target samples are labeled.\n\n### Proposed solutions\n\nWhen dealing with **Deep Domain Adaptation** problems, there are three main ways to solve them:\n\n1. **discrepancy-based methods**: align domain data representation with statistical measures;\n2. **adversarial-based methods**: involve also a domain discriminator to enforce domain confusion;\n3. **reconstruction-based methods**: use an auxiliary reconstruction task to ensure a domain-invariant feature representation.\n\nThe repository contains a possible solution for each one of the methods depicted above, together with a customized solution which combines two of them: discrepancy-based and reconstruction-based (`DSN` + `MEDM`).\n\nHaving only few examples available, training a network from scratch has not given satisfactory results; that is the reason why we have decided to always start with a feature extractor pre-trained on the [ImageNet](https://ieeexplore.ieee.org/document/5206848) object recognition dataset.\n\nMoreover, in order to delve into the proposed methods, we have given the opportunity to evaluate the domain adaptation method starting from two different backbones networks, namely [AlexNet](https://proceedings.neurips.cc/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf) and [ResNet18](https://arxiv.org/abs/1512.03385?context=cs).\n\n### Network Architectures\n\nTo successfully meet the domain adaptation challenge, we have implemented several network architectures which are then adopted from relevant papers in the literature and altered to fit our needs.\n\nOur major goal, as stated in the introduction, is to evaluate the performance (gain) of some of the most significant approaches in the domain adaptation field and build them on top of two of the most relevant convolutional neural network architectures, namely `AlexNet` and `ResNet`.\n\nIn this repository we cover:\n- [Deep Domain Confusion Networks](https://arxiv.org/abs/1412.3474)\n- [Domain Adversarial Neural Network](https://arxiv.org/abs/1505.07818)\n- [Domain Separation Networks](https://arxiv.org/abs/1608.06019)\n- [Rotation loss Network](https://arxiv.org/pdf/2010.07539.pdf)\n- [Entropy Minimization vs. Diversity Maximization for Domain Adaptation](https://arxiv.org/pdf/2002.01690.pdf)\n- A trial of ours to combine `MEDM` with `DANN`\n- Another idea of ours to combine `MEDM` with `DSN`\n\n## Results\n\nIn this project we have tried out at least one architecture for each domain adaptation category of techniques, namely `discrepancy-based`, `adversarial-based` and `reconstruction-based`. Among them, the most effective ones were `DANN` and `MEDM`.\n\n`MEDM` is an approach that can be easily integrated in any architecture, since it consists of two simple entropy losses, showing a stable training and astonishing performance. On the other hand, `DANN` is much more subject to hyperparameter variations and it is very likely to end up in an unstable training.\n\nIn our testing, we found that `DSN` and `MEDM` worked effectively together, whereas `MEDM` and `DANN` combined have not given a consistent improvement.\n\nSince it's more difficult to adapt from product to real world, gain is significantly simpler to obtain because there is far more space for improvement between the baseline and upper bound.\nOn the other hand, switching between real world and product images guarantees higher accuracy because networks have already seen real world images since they were pre-trained on `ImageNet`.\nAs a result, the gap between the baseline and the real world is significantly narrower, which means getting a significant progress is much harder.\n\nAfter having tried out both `AlexNet` and `ResNet18` as backbone architectures, we found that not only did `ResNet18` have far higher baseline and upper-bound values, but also all domain adaption strategies produced significantly larger gains.\n\nThe `t-SNE` plots has clearly shown our last solution is able to extract relevant features from both domains while performing an accurate classification, since the distributions are close to the optimal ones, which are those of the upper bound `ResNet18` model.\n\n### Distribution allignment plots\n\nWe have provided some plots to observe how the features of target and source domain are distributed thanks to dimensionality reduction techniques.\n\nHere, for instance, we have shown the `product-to-real-world` domain adaptation, considering only the model that has achieved the best performance, namely `DSN` + `MEDM`. So as to give an effective representation of the distribution alignment and provide a single graph, which is the most significant one regarding our project.\n\nIn the following sections two graphs are presented:\n\n- one depicting the distribution of the features learned by backbone neural network (ResNet18 in both cases) without considering the classifier or bottleneck layers.\n- one portraying the predicted class distribution.\n\n\u003e **Note**: that in both cases the plots are computed on the target domain (`real-world`), on which the `DSN+MEDM` approach has not access.\n\nIdeally, we would like that our domain adaptation model achieves the performances of the upper-bound model, which is the one that best generalize the source and target domain samples.\n\nTherefore, the model feature distribution is a good method to assess the quality of the domain adaptation technique.\n\nUpper bound features distribution on the test set:\n\n![upper bound features distribution](./.github/upperbound_features.png)\n\nUpper bound classes distribution on the test set:\n\n![upper bound classes distribution on test set](./.github/upperbound_classes_on_target.png)\n\nWe expect that both the classes and the features distribution are arranged in a similar way with respect to the Target distributions, as the model has achieved astonishing performances.\n\n`DSN + MEDM` features distribution on the test set:\n\n![DSN + MEDM features distribution](./.github/dsn_medm_features.png)\n\nAs we can see from the classes distributions below, even the model's classifier is able to effectively cluster the examples while maintaining a high accuracy. Clusters are well defined and separated between them. Despite being examples of the target domain, they are correctly classified.\n\n`DSN + MEDM` classes distribution on the test set:\n\n![DSN + MEDM classes distribution on test set](./.github/upperbound_classes_on_target.png)\n\nIn both cases, PCA hasn't really provided useful insights about the results, since a linear transformation may be too naive to transform such high dimensional data into a lower dimensional embedding.\n\n### Performances\n\nHere we provide the results we have achieved on the smaller version of Adaptiope:\n\n| **Backbone Network** | **Method**       | **Source set** | **Target set**    | **Accuracy on target (\\%)**          | **Gain** |\n|--------------------  |------------------|----------------|-------------------|--------------------------------------|----------|\n| AlexNet              | Source Only      | Product Images | Real Life         | 64.45                                | 0        |\n| ResNet18             | Source Only      | Product Images | Real Life         | 75.39                                | 0        |\n| AlexNet              | Upper Bound      | Product Images | Real Life         | 85.94                                | 21.485   |\n| ResNet18             | Upper Bound      | Product Images | Real Life         | 96.88                                | 20.312   |\n| AlexNet              | DDC              | Product Images | Real Life         | 68.36                                | 3.91     |\n| ResNet18             | DDC              | Product Images | Real Life         | 83.50                                | 8.11     |\n| AlexNet              | DANN             | Product Images | Real Life         | 65.23                                | 0.78     |\n| ResNet18             | DANN             | Product Images | Real Life         | 87.11                                | 11.72    |\n|                      | OriginalDSN      | Product Images | Real Life         | 04.17                                |          |\n| AlexNet              | BackboneDSN      | Product Images | Real Life         | 58.85                                | -5.60    |\n| ResNet18             | BackboneDSN      | Product Images | Real Life         | 78.39                                | 3.00     |\n| ResNet18             | OptimizedDSN     | Product Images | Real Life         | 81.25                                | 5.86     |\n| ResNet18             | Rotation Loss    | Product Images | Real Life         | 73.83                                | -1.56    |\n| ResNet18             | MEDM             | Product Images | Real Life         | 90.36                                | 14.97    |\n| ResNet18             | MEDM + DANN      | Product Images | Real Life         | 80.21                                | 4.82     |\n| ResNet18             | MEDM + DSN       | Product Images | Real Life         | 91.15                                | 15.76    |\n| AlexNet              | Source Only      | Real Life      | Product Images    | 85.55                                | 0        |\n| ResNet18             | Source Only      | Real Life      | Product Images    | 93.75                                | 0        |\n| AlexNet              | Upper Bound      | Real Life      | Product Images    | 95.70                                | 10.15    |\n| ResNet18             | Upper Bound      | Real Life      | Product Images    | 98.05                                | 4.3      |\n| AlexNet              | DDC              | Real Life      | Product Images    | 82.03                                | -3.52    |\n| ResNet18             | DDC              | Real Life      | Product Images    | 94.53                                | 0.78     |\n| AlexNet              | DANN             | Real Life      | Product Images    | 83.98                                | -1.57    |\n| ResNet18             | DANN             | Real Life      | Product Images    | 96.09                                | 2.34     |\n|                      | OriginalDSN      | Real Life      | Product Images    | 04.17                                |          |\n| AlexNet              | BackboneDSN      | Real Life      | Product Images    | 84.11                                | -1.44    |\n| ResNet18             | BackboneDSN      | Real Life      | Product Images    | 91.41                                | -2.34    |\n| ResNet18             | OptimizedDSN     | Real Life      | Product Images    | 93.49                                | -0.26    |\n| ResNet18             | Rotation Loss    | Real Life      | Product Images    | 91.80                                | -1.95    |\n| ResNet18             | MEDM             | Real Life      | Product Images    | 97.14                                | 3.39     |\n| ResNet18             | MEDM + DANN      | Real Life      | Product Images    | 94.00                                | 0.25     |\n| ResNet18             | MEDM + DSN       | Real Life      | Product Images    | 96.61                                | 2.86     |\n\n## Requirements\n\nThe code as-is runs in Python 3.7 with the following dependencies\n\n- [torch](https://pytorch.org/)\n- [torchvision](https://github.com/pytorch/vision)\n- [wandb](https://wandb.ai/)\n- [matplotlib](https://matplotlib.org/)\n- [seaborn](https://seaborn.pydata.org/)\n\nAnd the following development dependencies\n\n- [Sphinx](https://www.sphinx-doc.org/en/master/)\n- [black](https://black.readthedocs.io/en/stable/)\n\n## Getting Started\n\nFollow these instructions to set up the project on your PC.\n\nMoreover, to facilitate the use of the application, a Makefile has been provided; to see its functions, simply call the appropriate help command with [GNU/Make](https://www.gnu.org/software/make/)\n\n ```bash\n make help\n ```\n\n### 1. Clone the repository\n\n ```bash\n git clone https://github.com/samuelebortolotti/uda.git\n cd uda\n ```\n\n### 2. Install the requirements\n\n```bash\npip install --upgrade pip\npip install -r requirements.txt\n```\n\n\u003e **Note**: it might be convenient to create a virtual enviroment to handle the dependencies.\n\u003e \n\u003e The `Makefile` provides a simple and convenient way to manage Python virtual environments (see [venv](https://docs.python.org/3/tutorial/venv.html)).\n\u003e In order to create the virtual enviroment and install the requirements be sure you have the Python 3.7 (it should work even with more recent versions, however I have tested it only with 3.7)\n\u003e ```bash\n\u003e make env\n\u003e source ./venv/uda/bin/activate\n\u003e make install\n\u003e ```\n\u003e Remember to deactivate the virtual enviroment once you have finished dealing with the project\n\u003e ```bash\n\u003e deactivate\n\u003e ```\n\n### 3. Generate the code documentation\n\nThe automatic code documentation is provided [Sphinx v4.5.0](https://www.sphinx-doc.org/en/master/).\n\nIn order to have the code documentation available, you need to install the development requirements\n\n```bash\npip install --upgrade pip\npip install -r requirements.dev.txt\n```\n\nSince Sphinx commands are quite verbose, I suggest you to employ the following commands using the `Makefile`.\n\n```bash\nmake doc-layout\nmake doc\n```\n\nThe generated documentation will be accessible by opening `docs/build/html/index.html` in your browser, or equivalently by running\n\n```bash\nmake open-doc\n```\n\nHowever, for the sake of completness one may want to run the full Sphinx commands listed here.\n\n```bash\nsphinx-quickstart docs --sep --no-batchfile --project unsupervised-domain-adaptation --author \"Samuele Bortolotti, Luca De Menego\"  -r 0.1  --language en --extensions sphinx.ext.autodoc --extensions sphinx.ext.napoleon --extensions sphinx.ext.viewcode --extensions myst_parser\nsphinx-apidoc -P -o docs/source .\ncd docs; make html\n```\n\n\u003e **Note**: executing the second list of command will lead to a slightly different documentation with respect to the one generated by the `Makefile`.\n\u003e This is because the above listed commands do not customize the index file of Sphinx. This is because the above listed commands do not customise the index file of Sphinx.\n\n### 4. Prepare the dataset \n\nTo prepare the Adaptiope dataset filtered out, you can type:\n\n```bash\npython -m uda dataset [--classes ADDITIONAL_CLASSES --destination-location DATASET_DESTINATION_LOCATION --new-dataset-name FILTERED_DATASET_NAME]\n```\n\nwhere `classes` is the list of additional classes to filter out, by default they are:\n\n```python\nclasses = [\n    \"backpack\",\n    \"bookcase\",\n    \"car jack\",\n    \"comb\",\n    \"crown\",\n    \"file cabinet\",\n    \"flat iron\",\n    \"game controller\",\n    \"glasses\",\n    \"helicopter\",\n    \"ice skates\",\n    \"letter tray\",\n    \"monitor\",\n    \"mug\",\n    \"network switch\",\n    \"over-ear headphones\",\n    \"pen\",\n    \"purse\",\n    \"stand mixer\",\n    \"stroller\",\n]\n```\n\n`destination_location` refers to the name of the `zip` folder of the Adaptiope dataset which will be downloaded automatically by the script; whereas `new-dataset-name` is the name\nof the new filtered dataset folder. \n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake dataset\n```\n\n### 5. Visualize the dataset\n\nTo have a simple overview of how a label in the dataset looks like you can type:\n\n```bash\npython -m uda visualize DATASET_SOURCE DATASET_DEST LABEL [--batch-size BATCH_SIZE]\n```\n\nwhere `DATASET_SOURCE` is the source dataset folder, `DATASET_DEST` is the destination dataset location and `LABEL` is the label of the data you want the script to display.\n\nAs an effective representation the command:\n\n```bash\npython -m uda visualize adaptiope_small/product_images adaptiope_small/real_life 8\n```\n\ngives the following result:\n![Glasses from the dataset](.github/dataset_visualization.png)\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake visualize\n```\n\n\u003e **Note:** by default the `adaptiope_small/product_images`, `adaptiope_small/real_life` and `8` respectively as `SOURCE_DATASET`, `TARGET_DATASET` and `LABEL` will be employed, to override them you can refer to the following commmand:\n\u003e ```bash\n\u003e make visualize SOURCE_DATASET=sample/real TARGET_DATASET=sample/fake LABEL=9\n\u003e ```\n\nThe main idea behind the working behaviour of the visualization is very simple since it extracts one random batch from both domains and looks for the images with the specified labels within it. \n\nTherefore, **there may be some cases in which the images with the wanted label are not contained and thus not shown**, in this scenario I suggest you to increase the batch size or to run again the command.\n\nWe know that this functionality is limited and very naive but for our purposes it is more than enough.\n\n### 6. Run an experiment\n\nTo run the unsupervised domain adaptation experiment you can type:\n\n```bash\npython -m uda experiment POSITIONAL_ARGUMENTS [OPTIONAL_ARGUMENTS]\n```\n\nwhose arguments can be seen by typing:\n\n```bash\npython -m uda experiment --help\n```\n\nwhich are:\n\n```bash\npositional arguments:\n  {0,1,2,3,4,5,6,7,8,9}\n                        which network to run, see the `Technique` enumerator in `uda/__init__.py` and select the one\n                        you prefer\n  source_data           source domain dataset\n  target_data           target domain dataset\n  exp_name              name of the experiment\n  num_classes           number of classes [default 20]\n  pretrained            pretrained model\n  epochs                number of training epochs\n  {alexnet,resnet}      backbone network\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --wandb WANDB, -w WANDB\n                        employ wandb to keep track of the runs\n  --device {cuda,cpu}   device on which to run the experiment\n  --batch-size BATCH_SIZE\n                        batch size\n  --test-batch-size TEST_BATCH_SIZE\n                        test batch size\n  --learning-rate LEARNING_RATE\n                        learning rate\n  --weight-decay WEIGHT_DECAY\n                        sdg weight decay\n  --momentum MOMENTUM   sdg momentum\n  --step-decay-weight STEP_DECAY_WEIGHT\n                        sdg step weight decay\n  --active-domain-loss-step ACTIVE_DOMAIN_LOSS_STEP\n                        active domain loss step\n  --lr-decay-step LR_DECAY_STEP\n                        learning rate decay step\n  --alpha-weight ALPHA_WEIGHT\n                        alpha weight factor for Domain Separation Networks\n  --beta-weight BETA_WEIGHT\n                        beta weight factor for Domain Separation Networks\n  --gamma-weight GAMMA_WEIGHT\n                        gamma weight factor for Domain Separation Networks\n  --save-every-epochs SAVE_EVERY_EPOCHS\n                        how frequent to save the model\n  --reverse-domains REVERSE_DOMAINS\n                        switch source and target domain\n  --dry DRY             do not save checkpoints\n  --project-w PROJECT_W\n                        wandb project\n  --entity-w ENTITY_W   wandb entity\n  --classes CLASSES [CLASSES ...], -C CLASSES [CLASSES ...]\n                        classes provided in the dataset, by default they are those employed for the project\n```\n\nwhere `technique` refers to:\n\n```python\nclass Technique(Enum):\n    r\"\"\"\n    Technique enumerator.\n    It is employed for letting understand which method to use\n    in order to train the neural network\n    \"\"\"\n    SOURCE_ONLY = 1  # Train using only the source domain\n    UPPER_BOUND = 2  # Train using the target domain too, to fix an upper bound\n    DDC = 3  # Deep Domain Confusion\n    DANN = 4  # Domain-Adversarial Neural Network\n    DSN = 5  # Domain Separation Network\n    ROTATION = 6  # Rotation Loss\n    MEDM = 7  # Entropy Minimization vs. Diversity Maximization\n    DANN_MEDM = 8  # DANN with Entropy Minimization vs. Diversity Maximization\n    DSN_MEDM = 9  # DSN with MEDM\n```\n\nAs an effective representation the command:\n\n```bash\npython -m uda experiment 7 adaptiope_small/product_images adaptiope_small/real_life \"trial\" 20 pretrained 20 resnet\n```\nwhich will produce something similar to the following result:\n\n![DSN + MEDM features distribution](./.github/dsn_medm_features.png)\n![DSN + MEDM classes distribution on test set](./.github/upperbound_classes_on_target.png)\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake experiment\n```\n\n\u003e **Note:**  The current behavior is equivalent to \n\u003e ```bash\n\u003e python -m uda 7 adaptiope_small/product_images adaptiope_small/real_life \"medm\" 20 pretrained 20 resnet --learning-rate 0.001 --batch-size 32 --test-batch-size 32 \n\u003e ```\n\u003e you can change the behaviour by passing the parameters to the `Makefile` or by modifying its variables directly.\n\n## Jupyter Notebook\n\nIf you are interested in running all the experiments we have performed at once, we suggest you to execute the jupyter notebook [in the repository](uda/notebook/notebook.ipynb).\n\nSuch notebook has been run on [Google Colab](https://colab.research.google.com), therefore you can effortless run it from there as a powerful enough GPU and all the required libraries are provided.\n\n### Prepare the dataset\n\nIf you are willing to run the notebook be sure you have a copy of the zip archive of the Adaptiope dataset, which is available [here](https://gitlab.com/tringwald/adaptiope), placed in your Google Drive folder inside a directory called `datasets`.\n\nPractically speaking, the notebook will try to filter out the Adaptiope dataset by accessing `My Drive/datasets/Adaptiope.zip` after having established a connection to your Google Drive storage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelebortolotti%2Fuda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelebortolotti%2Fuda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelebortolotti%2Fuda/lists"}