Rolling bearing fault diagnosis is one of crucial tasks in mechanical equipment fault diagnosis. Currently, artificial intelligence and machine learning-driven fault diagnosis methods are extensively utilized for rolling bearing. When compared to traditional techniques, the diagnostic accuracy has significantly improved. These methods, however, need a substantial amount of labelled training data, which is difficult to obtain in actual failures. In order to resolve this problem, Transfer Learning (TL) was created to learn in the target domain by accessing knowledge from the pertinent labelled source domain. Inspired by Maximum Mean Discrepancy, this paper puts forward a Convolutional Neural Network (CNN) based Two-layer Transfer Learning (CTTL) method for fault diagnosis. In the first layer, the fault features are automatically extracted by CNN and a term called Feature Weighted Maximum Mean Discrepancy (WMMD) is considered to minimise the difference between source and target domains. In the second layer, the Third Dataset, which is based on the Density-Based Spatial Clustering of Applications with Noise (DBSCAN) method was designed on the basis of the predicted labels from the first layer. The Calinski-Harabaz (CH) index of the Target Dataset controls the iteration times of CTTL. CTTL change the process of Transfer Learning method from learning the distribution of domains to learning the distribution of fault types in more detail, which will get higher accuracy. Proposed CTTL is tested by the bearing datasets of Case Western Reserve University (CWRU) and XJTU-SY. The experimental findings reveal that CTTL is capable of achieving a high diagnosis accuracy across different load domains. In the majority of experiments, CTTL outperformed other algorithms, including Deep Neural Network, Support Vector Machine, and several other methods.