From Images to Features: Unbiased Morphology Classification via Variational Auto-Encoders and Domain Adaptation

We present a novel approach for the dimensionality reduction of galaxy images by leveraging a combination of variational auto-encoders (VAE) and domain adaptation (DA). We demonstrate the effectiveness of this approach using a sample of low redshift galaxies with detailed morphological type labels from the Galaxy-Zoo DECaLS project. We show that 40-dimensional latent variables can effectively reproduce most morphological features in galaxy images. To further validate the effectiveness of our approach, we utilised a classical random forest (RF) classifier on the 40-dimensional latent variables to make detailed morphology feature classifications. This approach performs similarly to a direct neural network application on galaxy images. We further enhance our model by tuning the VAE network via DA using galaxies in the overlapping footprint of DECaLS and BASS+MzLS, enabling the unbiased application of our model to galaxy images in both surveys. We observed that DA led to even better morphological feature extraction and classification performance. Overall, this combination of VAE and DA can be applied to achieve image dimensionality reduction, defect image identification, and morphology classification in large optical surveys.


INTRODUCTION
Galaxy images contain a wealth of information about their morphologies and structural properties.Traditionally, these morphologies were determined through visual inspection of the images, considering features such as bulges, disks, spiral arms, and bars.It has been shown that galaxy morphologies are closely linked to other physical properties such as color, stellar population, structural parameters, and even the environments in which they are found (e.g.Searle et al. 1973;Dressler 1980;Strateva et al. 2001).
Deep learning techniques have made significant progress in computer vision classification of natural images in recent years, and they have also been applied to various morphology-related problems in astronomy.Astronomical images, a type of natural image with a low signal-to-noise ratio, can particularly benefit from these new de-★ Contact Email: xuquanfeng@shao.ac.cn † Contact Email: ssy@shao.ac.cn ‡ Contact Email: rd23aag@herts.ac.uk velopments in computer vision.For example, Petrillo et al. (2017) used convolutional neural networks (CNNs) to identify strong gravitational lenses in the Kilo Degree Survey.Aniyan & Thorat (2017) applied CNNs to classify radio galaxies in archival data from the Very Large Array, and Ćiprĳanović et al. (2020) used CNNs to distinguish between merging and non-merging galaxies in simulated images at high redshift.Zhu et al. (2019) utilized CNNs to classify galaxies in the Galaxy Zoo 2 catalogue (GZ2; Willett et al. 2013a) into five morphological categories, achieving a high classification accuracy of 95.21%.Other studies have also utilized deep learning techniques to study various astronomical phenomena such as identifying bars in galaxies (Cavanagh & Bekkiet al. 2020) and microlensing events (Mróz 2020).Vavilova et al. (2021) evaluated the effectiveness of an auto-classification algorithm on galaxy images in the Sloan Digital Sky Survey (SDSS) Ninth Data Release (Ahn et al. 2013) and found that the accuracy of predicted galaxy morphology is largely independent of the redshift over the range 0.02<z <0.1 (see also Huertas-Company et al. 2018;Cheng et al. 2021b;Li 2022a).Furthermore, many other algorithms based on supervised deep learning have been applied to various galaxy morphology-related problems, such as estimating morphological parameters (Ghosh 2021), fitting light profiles (Li 2022b), and image deblending (Boucaud 2020;Wang et al. 2022).Supervised deep learning algorithms are commonly used for morphological classification of galaxy images, but they require a large amount of expert effort to annotate the data.Moreover, galaxy images from different astronomical surveys may have significant variations in survey parameters, such as point spread function, magnitude, and surface brightness limits.As a result, a classification network trained on data from one survey may not be effective when applied to data from another survey.
Alternatively, unsupervised learning methods can discover internal features of galaxy images and are more adaptable to galaxy images under different survey parameters.For instance, Martin et al. (2019) succeeded in classifying images of astronomical targets into four morphological categories (spirals, S0/Sa galaxies, ellipticals, and stars) by extracting morphological features from images through growing neural gas and hierarchical clustering algorithms.In another approach, Hayat et al. (2021) employed a self-supervised network to extract the morphological features of galaxy images in the GZ2 dataset (see also Wei et al. 2022;Fielding et al. 2022;Hocking et al. 2018).
Both supervised and unsupervised learning algorithms for galaxy morphology typically begin with the extraction of high-dimensional features from raw image data, followed by dimensionality reduction to a lower-dimensional space for the final classification or clustering.Dimensionality reduction can also enhance the comprehensibility of the data by reducing noise in low SNR astronomical images (see Hovis-Afflerbach et al. 2021).In fact, various dimensionality reduction algorithms have been applied to different aspects of astronomical data (e.g.Kartaltepe et al. 2015).
In addition, as a low SNR image, the application of the dimensionality reduction algorithm on astronomical images may further reduce the noise and thus enhance the comprehensibility of the data (see Hovis-Afflerbach et al. 2021).Indeed, different dimensionality reduction algorithms have been applied to many aspects of astronomical data (e.g.Kartaltepe et al. 2015).For instance, Uzeirbegovic et al. (2020) applied principal component analysis (PCA) to images of galaxies in the Galaxy Zoo CANDELS GOODS-S sample (Simmons et al. 2016) and found that the images of galaxies can be represented by just 12 eigengalaxies while retaining 96% of their variance.However, as high-dimensional complex data, astronomical images may not be fully expanded in linear space, particularly for morphology-related data structure features.Therefore, deep learning methods for the nonlinear dimensionality reduction of galaxy images is worth exploring.
The Variational AutoEncoder (VAE) (Kingma & Welling et al. 2013) is a self-supervised learning method that combines an encoder and a decoder structure to map between images and features, ensuring that images with similar morphological features will also be similar in latent variable distribution.This has resulted in the VAE algorithm being applied to astronomy for feature extraction and image generation (Lanusse et al. 2021).For instance, Cheng et al. (2021a) used Vector Quantized VAE to extract morphological features of -band images from SDSS DR7 data, and found that the latent variables were highly correlated with the physical properties of galaxies.Despite these advances, aspects of deep learning-based galaxy morphological feature extraction algorithms are still yet to be explored.One is how many dimensions of latent parameters can adequately express the basic morphological features of galaxies.
Recent studies have shown the potential of deep learning mod-els in describing the morphology of galaxies through the use of latent variable parameter spaces.For example, Hayat et al. (2021) demonstrated that self-supervised learning could recover semantically useful representations of sky survey images, which can be used as features without needing labelled data.Using a 2048-dimensional latent variable parameter space, their method achieved similar accuracy as supervised models while using 2-4 times fewer labels for training.Lanusse et al. (2021) simulated galaxy images from only 16d latent variables and obtained a much better description of galaxy morphology than the traditional single Sérsic model.Zhou et al. (2021a) combined a convolutional autoencoder and a bagging-based multiclustering model for morphological classification of galaxies in CANDELS.
Deep learning models also demonstrate robustness against naturally occurring perturbations in low signal-to-noise ratio astronomical images (Ćiprĳanović et al. 2022).Ćiprĳanović et al. (2023) showed that domain adaptation techniques can make the performance of deep learning models on morphology classifications consistent across different astronomical datasets.Vilalta et al. (2019) present a new domain adaptation method that relies on comparable model complexity rather than source-target similarity, using active learning to reduce dependence on source data.Ćiprĳanović et al. (2021) apply domain adaptation techniques such as Maximum Mean Discrepancy (see more detail in Section 3.2), Domain-Adversarial Neural Network (DANN; Ganin et al. 2016), Fisher loss, and entropy minimization to train neural networks on simulation data, and then transfer these networks to telescope observations, thereby demonstrating significant improvements in classification accuracy.Gilda et al. (2022) utilizes unsupervised domain adaptation to accurately predict galaxies' star formation histories, by learning mappings between simulated galaxy models and present-day observations.Therefore, applying domain adaption algorithms to the dimensionality reduction tasks in astronomical images could further improve the ability to extract effective features from image data.
This paper is structured as follows.In Section 2 we describe the main galaxy sample in the DESI legacy survey and the GZ-DECaLS dataset, which offers the most detailed morphological classification to date.In Section 3 we introduce our use of the VAE model to perform non-linear dimensionality reduction of galaxy images.In Section 4, we discuss our choice for the dimensionality of the latent space to perform morphological classification.Section 5 discusses a domain adaption approach for galaxies outside the DECaLS footprint to make the dimensionality reduction algorithm robust against perturbations such as differences in point spread function, image resolution, and noise.Finally, we discuss our findings' results and implications in Section 6.

Main galaxy sample in the DESI legacy survey
The Main Galaxy Sample (MGS) is a sample of low redshift galaxies limited by flux and defined as having an r-band magnitude <17.77.Initially designed by the SDSS (Strauss et al. 2002), it contains approximately 700,000 galaxies within the SDSS legacy survey footprint.Most galaxies in the MGS have obtained fiber spectroscopy, and their median redshift is about 0.1 (Abazajian et al. 2009).This study uses images of the MGS from the DESI Legacy Imaging Surveys (DESI, Dey et al. 2019), which provide deeper images of the extragalactic sky in the , , and  bands over an area of approximately 14,000  2 .The DESI Legacy Survey comprises three public projects: the Dark Energy Camera Legacy Survey (DECaLS), the Beĳing-Arizona Sky Survey (BASS), and the Mayall z-band Legacy Survey (MzLS).These surveys use two different telescopes and complement each other regarding the sky coverage and the survey bands while differing slightly in their observational parameters, such as image resolution and exposure time.The parameters for each survey are listed in Table 1.

Galaxy Zoo DECaLS
In the DECaLS footprint of the MGS, the Galaxy Zoo DECaLS project has provided visual morphology measurements for a sample of approximately 314,000 galaxies (Willett et al. 2013b).Visual classifications of the volunteers for GZ DECaLS were collected during three campaigns, GZD-1, GZD-2, and GZD-5.The classifications were based on different decision trees, and the classified data were released in DECaLS Data Releases 1, 2, and 5, respectively.GZD-5 used an improved decision tree aimed at better identification of mergers and weak bars compared to GZD-1/2.Using the GZD-5 classifications, Willett et al. (2013b) trained an ensemble of Bayesian convolutional neural networks on the sample galaxies with at least three votes and successfully predicted the posteriors for the detailed morphology of all 314,000 galaxies under the GZD-5 decision tree.In the released catalog 1 , each galaxy has been assigned likelihoods for each morphology label question following the GZD-5 decision tree (Fig. 1).
In this study, we use the 314,000 GZ-DECaLS galaxies as the training sample of the VAE network to establish a mapping between the latent variables and morphological labels.For ease of use, we label the morphological parameters of each galaxy based on the probabilities of choices in each branch of the GZD-5 decision tree.Specifically, we split the GZD-5 decision tree into nine different morphological features: how rounded, edge-on, bulge shape, bar, have arm, arm tightness, arm count, bulge size, and merger.For the abovementioned 9 morphological features, we followed Walmsley et al. (2022) to arrange them in the decision tree and classified the presence or degree of each morphological feature by two to three to obtain a total of 24 characteristics.Using the decision tree and probability of morphological parameters, we identify 24 different morphological types for GZD-5 galaxies by setting the individual fraction threshold at 0.6.In order to keep the sample size as balanced as possible between the various types, we set the non-merger type threshold at 0.8.This was done to mitigate the impact of data imbalance on the model and results.The selection criteria and the resulting number of sample galaxies for each morphological type are listed in Table 2.

4573248
Table 2. Selection criteria and sample sizes for 24 galaxy samples and respective morphological parameters for a set of questions about their morphology.For each case, we provide the fraction threshold.

Variational Autoencoders
The VAE architecture (Kingma & Welling et al. 2013) consists of an encoder and a decoder, each with its own set of learnable parameters.The encoder, with encoding parameters , maps the highdimensional input data  to a low-dimensional latent variable representation  through the probability distribution   (|).With decoding parameters , the decoder maps the latent variables back to the high-dimensional feature space, generating the reconstructed data x by   (|) and .Both   (|) and   (|) are parameterized by a neural network.
In addition to the encoder and decoder networks, the VAE architecture includes a stochastic variational inference step.During this step, the model computes the mean () and variance () of the latent variable features.These statistics are used to construct a highdimensional normal distribution for all latent variables.The model then samples the latent variable features from this distribution to generate the corresponding high-dimensional data.
By using the stochastic variational inference technique, the VAE can learn a probability distribution over the latent variables that capture the underlying structure of the input data.The distribution is typically assumed to be a multivariate Gaussian with diagonal covariance, allowing efficient computation and sampling With   (), the reconstructed data then is simply x Here  is a hyper-parameter that balances two loss components.In this study, we set  as 1.Besides , the number of latent variables   is the other hyper-parameter affecting the reconstruction effect in the VAE model, which we will probe in detail in Section 4.1.Overall, the VAE architecture provides a robust framework for learning compressed representations of high-dimensional data that can be used for various downstream tasks such as image generation, data compression, and data analysis.
The VAE model structure in this paper is illustrated in Figure 2, consisting of an encoder, a latent variable reconstruction, a decoder, and a final layer.The encoder comprises three encoder blocks, each containing a convolutional layer, a maximum pooling layer, and an activation layer.The three input channels of the first encoder block correspond to the , , and  bands, and the subsequent blocks build upon the previous block's output.The three encoder blocks have 32, 64, and 128 output channels.The encoder's high-dimensional output vectors are then flattened into two   -dimensional latent variables,  and , through two fully connected layers.For the decoding part, a   -dimensional latent variable feature  is sampled from highdimensional normal distributions with mean  and scatter .The decoder comprises three decoder blocks, each containing a transposed convolution, an upsampling layer, and an activation function.
The input channels for each decoder block are 128, 64, and 32, respectively.Finally, the convolutional layer and ReLU activation function of the final layer reconstruct images to their original sizes.

Domain Adaption
Deep learning models may struggle to perform well on different learning tasks due to differences in the data distributions between the source and target domains.This can be caused by diverse underlying astrophysical populations, but also, in the case of data coming from more than one observatory, differences in detector characteristics and observational conditions, to cite a few.In practical applications of deep learning, these differences in underlying statistical distributions can limit the generalization power of models.For example, feature extraction networks used for extracting galaxy morphological features through VAE may not be robust due to variations in data sources.Here we use domain adaptation to overcome some of these issues.Since images of the same celestial region obtained from different surveys intrinsically share identical physical properties, we sought to eliminate image differences caused by extrinsic variations in observational effects.
To quantify the difference between the source and target domains, Pan et al. (2008) proposed the maximum mean difference (MMD).MMD is defined as: where   and   represent the source and target domain data, and F is a space of functions.The equation defines the supremum of the expectation of the functional mapping between the source and target domains.Homogeneous transfer learning reduces the difference in data distribution between the source and target domains by decreasing the MMD.We will discuss the usage of MMD in domain adaptation in Section 5.2.

APPLICATION TO THE MGS IN DECALS
In this section, we use the VAE model to reduce the dimensionality of the , ,  band images of the MGS in DECaLS survey.In Section 4.1, we explore the optimised dimension of the latent variables in the VAE model.And in Section 4.2, we discuss the properties of the latent variable distribution and potential scientific applications.We then test the effectiveness of the morphology feature classification using the resulting latent variables from VAE model in Section 4.3.
Throughout the study, we use the Adam (?) optimizer for networks and set the learning rate to 0.0001, batch size to 512.We train this network for 100 epochs.

The dimensionality of latent variables
The dimension of the latent variable features   is the only hyperparameter in our VAE model.In principle, a higher   would, of course, contain more information, so that more comprehensive morphological features of galaxy images would be contained.On the other hand, a dimensionality reduction algorithm seeks to reduce the dimension of data as much as possible while preserving majority of the data feature.Thus, it is necessary to choose an appropriate dimension to balance the image reconstruction quality and the dimension of latent variables.
In this study, we tend to limit   in the range of 10 to 100.If the dimension of latent variables is too low (e.g.<10), we do not expect that the morphological information of galaxy images could be adequately contained by the latent variables.On the other hand, if the dimension of latent variables is too high (e.g.>100), the dimensionality reduction would not be very significant, and the resulting interpretability of the latent parameter becomes weaker.Based on the above considerations, we test 6 cases with   being 10, 20, 40, 60, 80, and 100 respectively.
We use the structural similarity index measure (SSIM) proposed by Wang et al. (2004), which is a measure of the similarity between the reconstructed image and the original.In this algorithm, the luminance     , x   , contrast     , x   , and structure     , x   of  ×  sliding windows at the same position (, ) of two images are first compared, where   ,  x and  2  ,  2 x are the mean and variance of the original and the reconstructed image windows respectively,   x is the covariance between the original and the reconstructed images in the same windows, and  1 ,  2 ,  3 are three constants.Following Wang et al. (2004), we set  1 = (0.01) 2 ,  2 = (0.03) 2 ,  3 =  2 /2, and  is the dynamic range of pixel values (255 for 8-bit grayscale images).The SSIM function is defined as Here, we set  =  =  = 1, following Wang et al. (2004).The global SSIM parameter is then calculated through the average values of continuously sliding windows.
From equation ( 5), the image similarity value evaluated by SSIM is between 0 and 1.The closer the similarity value is to 1, the more similar the images.
We evaluate the reconstruction performance for different dimensionality of latent parameters by the SSIM values of the reconstructed and the original images.Moreover, we adopt two loss functions, Mean Absolute Error (MAE) and Mean Squared Error (MSE), to optimize the VAE model.Figure 3 shows the reconstruction performance in different cases.As expected, SSIM values increase monotonously with   .Moreover, we find that SSIM values present a inflection point at   ∼ 40.
In addition, we compare the reconfiguration performance for galaxies with different morphology features.For each type of restructuring evaluation, only the first stage branch of the decision tree (the classification of yellow background in Figure 1) is selected for analysis and comparison.Figure 4 shows that the VAE model performs better in reconstructing images of cigar-shaped galaxies and elliptical galaxies, while poorer in images of disk galaxies with detailed structures.However, the SSIM evaluation indexes for dif-  ferent categories all show inflection points around   ∼ 40.Thus, considering the dimensionality of latent variables and the quality of reconstructed images, we select the experimental results with the loss function of MSE and latent variable parameters   = 40 for further investigation.

Visualization of Latent Variables
When projected onto a latent space, similar morphological features tend to cluster.We employ t-SNE (?) to reduce the 40-dimensional space to two dimensions, as illustrated in Figure 5.This figure showcases the density contours of the latent space.The left panel presents broader categories, while the right offers finer details.As the granularity increases, the latent space becomes denser and more intertwined.Importantly, we remind that this is just a visual representation of a 40-dimensional space where we expect morphological features to be more distinct.
A consequence of creating dense distributions in the latent space is the ability to search for outliers located far from its centers.As an illustration, we identified outliers in the latent space using a criterion of eight times the standard deviation for each latent parameter.This yielded 1,308 outliers, representing 0.417% of the total galaxy images.A random selection of these outliers is presented in Fig. 6.We display 32 example images of outliers from the 40-dimensional

Morphology Classification on Latent Variables
The variational framework of the VAE model ensures that galaxy images with similar morphological features exhibit similar behavior in the latent space, leading to a dense distribution of latent variable features in this low-dimensional space.Closely distributed and dense latent variables are not suitable for unsupervised clustering (e.g.Zhu et al. 2019;Nishikawa-Toomey et al. 2020;Wei et al. 2022).Therefore, in this section, we combine morphological labels to explore the morphological information contained in latent variables.Since latent variables already contain comprehensive information of galaxy images, we expect that directly using latent variables for morphological classification may simplify the classification logic and the number of operations.To test this idea, we adopt the random forest (Breiman et al. 2001), a classifier that uses multiple decision trees to train and predict samples, to classify the morphological labels using the latent variables.We employed the random forest algorithm from the sklearn package in Python, setting the number of decision trees to 100.Additionally, we adjusted the proportions of various categories to address the class imbalance.Specifically, we combined latent variables and morphological categories to form a dataset.We allocated 70% of these data for training and the remaining 30% for testing.During both training and testing phases, the random forests straightforwardly classified the latent variable features.To evaluate the effectiveness of the classification, we utilized precision, recall, and F-score as our performance metrics.
We train and test the morphological labels for nine morphological features (listed in Table 2) respectively.The accuracy of training and testing on the latent variables obtained by VAE is shown in Table 3.In general, we obtain a test accuracy of between 70% and 95% for different classifications of morphological features.Compared with the deep learning algorithms directly applied to the morphologies of galaxy images with typical supervise accuracy (>90%, Zhu et al. 2019), the accuracy of our test on latent variables are slightly lower.However, most of the previous studies only make general morphology classifications for few global labels (e.g.Cavanagh et al. 2021, classification disk/elliptical/merging).Few studies have addressed the classification of various detail morphological features, and the resulting classification accuracy is also comparable (e.g.active learning by Walmsley et al. 2022) to us.Specifically, the accuracy of our simple classifier on the spiral arms' tightness, bulge size and roundness is similar to that of Walmsley et al. (2022) study.In contrast, the classification of the merging (93.43% respectively) is even better.
Based on the above results, we see that these 40 latent variables output from the VAE dimensionality reduction algorithm can effectively retain the overall features of galaxy images (e.g.spiral/merging).Moreover, these features can be identified by simple classifiers such as random forests and so that used in the application of galaxy morphology classification.However, for these locally detailed morphological features (e.g. the arm tightness), they may not be effectively contained in low dimensional latent variables.

DOMAIN ADAPTION: MGS IN BASS AND MZLS
Because of different observational conditions, the images of galaxies in the different surveys would be different in detail (e.g.image resolution, PSF, and noise level).Therefore, an optimized image encoder should try to extract the physical (morphological) features of the images while ignoring the fluctuations caused by observational conditions.Only if so, we expect that such an image encoder could be unbiasedly applied to galaxy images from other surveys.In this section, we test the generalization ability of the image encoder in the VAE model we have obtained in Section 4, which is trained only by the DECaLS images and applies to BASS+MzLS images.

Original encoder applied to BASS+MzLS galaxy images
The parameters for three different programs of the DESI image survey are listed in Table 1.We would like to remind you that the DECaLS survey covers the , , and  bands, and all these bands have a uniform pixel resolution of 0. ′′ 262.The BASS and MzLS surveys have the same footprint, but it differs from that of the DECaLS survey.The BASS survey operates in the  and  bands and has a pixel resolution of 0. ′′ 454, whereas the MzLS survey is in the  band with a pixel resolution of 0. ′′ 262.The DECaLS survey and the combined BASS+MzLS survey overlap in a region of 2 degrees of declination, and the area of the overlapping sky covers about 100 square degrees.
In order to determine whether the encoder of the VAE algorithm trained on DECaLS images can be applied to BASS+MzLS (, , ) images, we used the galaxies located within the overlapping footprint of the two surveys.Specifically, we selected 3,434 galaxies in the MGS (<17.77)that were located within this overlapping region.We obtained images of these galaxies in both the MzLS and BASS surveys from the DESI website.To ensure consistency, we download the official offered  and  band BASS images with the same resolution as DECaLS, which was 0. ′′ 262.
To compare the latent variables of these 3,434 galaxies in the two surveys, we applied the encoder trained in Section 4.1 to their , ,  images from BASS+MzLS and obtained their 40-dimensional latent variables.We then compared this new set of latent variables with those obtained from DECaLS images.To quantify the differences between the latent variables for each galaxy, we used Mean Squared Error (MSE).
Although the images of these galaxies appear almost identical in the two different surveys (DECaLS vs. BASS+MzLS), we found differences in their latent variables.The MSE values of the latent variables ranged from as small as ∼ 0.05 to as large as 10.We show two groups of images with very different MSE values in Figure 7: one group with MSE <0.1 and another group with MSE >8.As expected, the group with small MSE values had almost identical images and showed little visual difference.For the group with very large MSE values, we observed contamination by a bright star nearby in most cases.We suspect that it is the bright star that led to significant differences in the latent variables after dimensionality reduction by the VAE encoder.
We further tested whether these latent variables of BASS+MzLS galaxies can be used to make morphology classifications, as we did in Section 4.3.We used the same random forest that was trained in Section 4.3 to test the morphology classification of these 3,434 galaxies.For simplicity, we only applied the random forest on some morphology features where the number of galaxy samples was larger than 100.The results are shown in Table 4.
As expected, compared to the DECaLS galaxy images, the morphological classification of the latent variables of BASS+MzLS galaxy images showed a significant decrease.In particular, for bar features of galaxies, the classification precision dropped from 82.53% to 70.59%, while for the merger features, the classification accuracy remained almost unchanged.This result suggests that the VAE encoder has successfully extracted some of the global morphology features of galaxy images (e.g., mergers).In contrast, random noises generated during observations affect some detailed morphology features (e.g., bar).

Optimized Encoder with Domain Adaptation
In the above section, we have demonstrated that slight differences in survey parameters prevent us from using the VAE encoder trained by DECaLS only on BASS+MzLS galaxies, even though the target galaxies are a homogeneous sample in both surveys.To solve this problem, we introduce the idea of domain adaption and MMD algorithm (Section 3.2).In our problem, we have a well-trained network in the source domain (DECaLS), which can well implement image In our model, this difference is the difference of latent variables obtained by the same VAE encoder for the same galaxies in two groups of surveys.By combining MMD with the existing VAE network (Fig. 2), we obtain a domain adaptation model, which is illustrated in Figure 8.In this network, the latent variables of the galaxy images in two different surveys are first extracted by the same encoder.Then two decoders are attached to reconstruct the images of the galaxies themselves.Using such a domain adaption model, the latent variables obtained by the encoder will better reflect the internal morphological features of the galaxy itself.In contrast, the differences in the galaxy images caused by different survey parameters are contained in two other decoders.
To perform domain adaptation, we augment the original VAE loss function with Maximum Mean Discrepancy (MMD) as follows: where  is the super-parameter that balanaces the loss from VAE and MMD networks,   denotes the encoder mapping that we aim to optimize.This domain-adapted deep learning network is based on the weights of the VAE model trained on the DECaLS (Section 4) and trained on the images of 3,434 galaxies in the overlapping regions of DECaLS and BASS+MzLS, which aims to learn latent variables (image features) that are invariant to differences between two surveys, allowing us to compare and analyze the same galaxies in different surveys (e.g.Pan et al. 2010).Here, we set  = 10 so that the final loss of MMD is of the same magnitude as that of the VAE network.For the training, we also set the learning rate to 0.0001 and used a smaller number of epoch 20.
To evaluate and compare the effectiveness of domain adaptation, we use the same random forest algorithm as in Section 4.3 to test the performance of morphological classification based on the learned latent variables.Since the latent variables are obtained from the newly adapted network, we retrain the random forest with 70% of the data for training and 30% for testing.This approach allows us to assess whether the domain adaptation process leads to more effective representations of galaxy images for classification purposes.
Given that this domain-adapted network was trained on only 3,434 galaxies, the number of galaxies with certain morphological features is quite limited.This restricts the effective training of subsequent random forest classification algorithms.For effective training, we required a minimum of ⪆ 200 galaxies.Consequently, only 7 out of the 9 galaxy features meet this criterion, as shown in Table 4.
We utilize the accuracy of the random forest to assess the feature extraction capability of the encoder.After implementing domain adaptation on the VAE model, there was a notable enhancement in the precision of the morphological features for the BASS+MzLS data,   as depicted in Table 4.For the DECaLS data, post-domain adaptation, precision improved for 5 out of the 7 features.Interestingly, when we compare the results of DECaLS data before domain adaptation to those of BASS+MzLS data after domain adaptation, we notice enhancements in the precision metrics for most features.Specifically, the precision for the 'arm tightness' feature rose from 61.76% to 69.12%, and the precision for the 'merger' feature went up from 97.95% to 98.53%.These results suggest that domain adaptation enables deep learning networks to extract more relevant internal features from galaxy images while reducing the influence of random fluctuations introduced by different observations.The increased classification accuracy provides evidence to support this idea.

CONCLUSION AND DISCUSSION
In this study, we applied VAE to the , ,  images of galaxies from the DECaLS survey, which were classified based on visual inspection.We found that a VAE algorithm with a latent variable dimension of   = 40 was effective in extracting morphological features from galaxy images.
To evaluate the quality of the reconstructed images, we used the structural similarity index (SSIM) and found that the VAE reconstructed images had SSIM values between 0.80-0.90for all morphological types of galaxies, indicating good image reconstruction.
After reducing the dimensionality of the galaxy images to a 40dimensional latent variable space, we used a classical random forest classifier to make detailed morphological classifications.The test accuracy varied between 0.71 to 0.94, depending on the morphological types.In general, the latent variables performed well on global mor-phological features (e.g.round, merger) and were slightly weaker on detailed features (e.g.bar/spiral arm).
To apply our VAE encoders to both the DECaLS and BASS+MzLS surveys, we tuned our network and adapted it for both surveys by adding MMD of the latent variables as a loss component.We then trained our algorithm using 3,434 galaxies in the overlapping footprint of the surveys.The results showed that our VAE algorithm was successfully adapted to the galaxy images of both surveys.
The latent variables extracted by the VAE encoder after domain adaptation (DA) performed better on galaxy morphology classification, indicating that the VAE encoder after DA was better at extracting internal features of galaxy morphology and was less affected by observational noise.
Our VAE framework has many potential applications in observational studies of galaxy morphologies.
First, the prior distribution of latent variables in the VAE algorithm ensures that galaxy images with similar latent variables are highly similar.Therefore, we can easily identify outliers in the galaxy images using the latent variables, such as images with defects or peculiar morphologies.As shown in Fig. 6, most of the outliers were images with defects.This demonstrates the ability of the VAE dimensionality reduction method to quickly and effectively detect defected images in modern and future image surveys, such as the CSST optical survey (Sun et al. 2021).In addition, we can also use this method to identify galaxies with peculiar morphologies, which will be the subject of a future study.
Secondly, our VAE decoders can be utilized to generate mock images at low redshifts.Similar studies have been conducted using deep galaxy images from the HST/ACS COSMOS survey (Lanusse et al. 2021).However, generating mock images that accurately reflect the characteristics of observed galaxies is challenging due to the varying redshift and apparent size distributions of galaxies in image surveys with different depths.Therefore, a VAE generative model based on shallow-ground survey data can provide a complementary approach to that of Lanusse et al. (2021).
In this study, we have demonstrated that the VAE model with DA can successfully be applied to both DECaLS and BASS+BzLS galaxy images.However, this finding alone does not justify the direct application of our VAE encoders to new sky surveys.The reason is that different surveys may have significantly different PSFs which moreover are expected to be position and time-dependent, as the instrument and site conditions evolve.The real, intrinsic image signals of astronomical objects are convolved with these highly complex PSFs, and this complexity is not expected to be easily captured by our current network.Additionally, different surveys may have vary-ing depths, meaning that fainter galaxies and those at higher redshifts may emerge as the survey depth increases.Thus, training an encoder of galaxy images that can be adapted to all galaxies in entirely different sky surveys requires further investigation.Nevertheless, the results presented here are evidence that the coherent combined application of machine learning concepts (VAE and DA) may be one possible path for the future development of multi-survey analysis.

Figure 3 .
Figure 3. Evaluation of SSIM reconstructed values in two loss functions with different dimensionality of latent variables for all images.

Figure 4 .
Figure 4. Evaluation of different latent variable dimensions in various categories of SSIM reconstructed values.

Figure 5 .
Figure 5.The plot displays t-SNE projections of our galaxy sample, with broad categorizations (Spirals vs. Ellipticals) and narrower classifications (No edge-on, edge-on, cigar, ellipse, rounded), each color-coded.As classifications refine, the projected latent space becomes increasingly intermingled.

Figure 8 .
Figure 8. Structural details of the Domain Adaptation based on VAE in this study.

Table 1 .
Survey parameters of DESI Legacy imaging surveys.

Table 3 .
Nine Random forests classification result of GZD-5 morphological feature questions.

Table 4 .
Comparison of random forest classification accuracy before and after VAE domain adaptation.