Giter Club home page Giter Club logo

domain_adaptation's Introduction

Domain_adaptation

Domain adaptation is a crucial aspect of machine learning and artificial intelligence that addresses the challenge of adapting a model trained on one domain to another domain with varying data distribution. The primary objective of domain adaptation is to enhance the performance of a model on a target domain by leveraging knowledge from a source domain. This approach is particularly useful when there is limited labeled data available for the target domain but abundant labeled data available for the source domain. Domain adaptation can be applied in diverse areas such as natural language processing, computer vision, speech recognition, and robotics.

One of the most effective techniques for solving domain adaptation problems is discriminative adversarial neural networks (DANN). By using DANN, I have successfully addressed a common issue in computer vision, where the feature distribution in the training dataset differs significantly from that in the test dataset.

dann

The primary objective of the DANN method is to discover a network that can extract data features from both the source and destination domains, making it difficult for another network, known as the discriminator network, to distinguish between them. This method aims to bring together the domain distributions by extracting and mapping features to different spaces.

According to the DANN method, three different networks are utilized. The encoder network is responsible for receiving input data and extracting its features. The extracted features are then fed into the classification and discriminator networks. The classification network predicts the data label of the source domain, while the discriminator network determines whether the data belongs to the source or destination domain.

To train these networks, we input tagged data from the source domain and untagged data from the destination domain into the network. After extracting desired data characteristics, if it belongs to the source domain, it is simultaneously fed into both classification and discriminator networks. However, if it belongs to the destination domain, it is only entered into the discriminator network. This way, only data from the source domain is used to train the classification network, while both domains are used for domain matching.

Another objective of the encoder network is to extract common features so accurately that even the discriminator network cannot correctly identify which data comes from which domain. In other words, it aims to deceive or trick the discriminator network into recognizing domains in reverse order. Thus, there exists an adversarial relationship between the encoder and discriminator networks. During training of the encoder network, feedback is received from both classifier and discriminator networks in order to update weights. As this relationship is adversarial in nature, feedback received from this network is multiplied by negative values.

In general, the cost functions of the Discriminative Adversarial Network (DANN) method can be expressed as follows:

Capture

These cost functions state that the network that receives the source and destination data, map them as ฯ†(XS) for the source data and as ฯ†(XT) for the destination data, and the cost of the discriminator network should be maximized and the sum of the costs of the classifier network and the negated cost of the discriminator network should be minimized.

In This project we used two datasets as my source and destination domains comprises images of four types of vehicles: bus, car, pickup, and truck. The Mio dataset was utilized for the source domain, consisting of vehicle photos captured by CCTV cameras on the streets. These images typically have higher clarity and are taken from horizontal or aerial angles. In contrast, the destination domain contains a blend of aerial and CCTV camera photos from the streets of Iran, which exhibit slightly lower image quality and may include smaller-sized images.

MIO dataset (Source Domain):


1 2 3 4


Iran's Vehicle dataset (Target Domain):

1 2

in order to showcase the effectiveness of Domain Adaptation techniqe for this image classification problem, first I trained Resnet50 network without domain adaptation (vehicle.ipynb) and then used DANN technique (vehicle_DANN.ipynb) to increace model accuracy by bringing domains' distributions closer to each other. The results showed that DANN significantly improved the model's performance on the target domain by effectively leveraging knowledge from the source domain.


Model Accuracy during training and data encoding of source and destination domains without DA :

Capture


Model Accuracy during training and data encoding of source and destination domains with DA :

2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.