A computer program product comprising a non-transitory computer readable storage medium having instructions encoded thereon that, when executed by a processor, cause the processor to perform steps comprising:
- applying a classification model to a target image for classification, wherein the classification model is trained by:
- accessing a first training set comprising first training examples each having a class label;
- accessing a second training set comprising second training examples each having a domain label;
- initializing a plurality of layers of a neural network, the plurality of layers including feature extractor layers configured to output a set of features that are input into each of a domain classifier set of layers and a class predictor set of layers and a gradient reversal layer coupling the feature extractor to the domain classifier, the gradient reversal layer configured to multiply data backpropagated from the domain classifier by a negative constant;
- selecting the class predictor set of layers or the domain classifier set of layers;
- responsive to selecting the class predictor set of layers, selecting a first example from the first training set and backpropagating through the class predictor set of layers and feature extractor layers of the model using a loss function based on matching output of the class predictor to the class label of the selected first example;
- and
- responsive to selecting the domain classifier set of layers, selecting a second example from the second training set and backpropagating through the domain classifier set of layers, gradient reversal layer, and feature extractor layers of the model using a loss function based on matching output of the domain classifier to the domain label of the second example;
- receiving an output from the classification model, the output comprising a class in a domain for the target image;
- and
- storing the received class in the domain in association with the target image.