## 1 Introduction  
Walnut, as a characteristic dried fruit in Xinjiang, is favored by consumers worldwide because of its outstanding taste and high nutritional value [1]. Considering the rising consumer demand for processed walnut products, the internal quality of walnuts with shells plays a crucial role in purchasing decisions. After picking, internal defects, such as protein deterioration, flavor loss, shriveled seed kernel, and empty shell, and external mechanical damage in walnuts can occur during transportation, processing, and storage [2]. These seriously reduced the grade and commodity rate of walnuts and greatly weakened their market competitiveness [3]. At present, the detection methods used to identify the internal quality of walnuts are manual detection, physical means, or stoichiometry. However, the methods are time-consuming, labor-intensive, and inherently destructive. Therefore, a quick, effective, and non-destructive method for determining the internal defects of walnuts is highly desirable. There are several common non-destructive detection-test methods in the field of industry and agriculture, such as machine vision, hyperspectral imaging, near-infrared spectroscopy, thermography, acoustic vibration method, magnetic resonance imaging (MRI), and X-ray imaging techniques. Machine-vision technology is limited to the detection of surface defects in objects and, thus, cannot effectively detect internal quality [4]. Hyperspectral imaging has disadvantages of more wavebands and large data volume, and the equipment is too expensive [5]. Near-infrared spectroscopy mainly provides a digital data analysis result that cannot visualize the internal defects, and requires high sample preparation and processing [6]. The acoustic vibration method has been highly susceptible to environmental impact, and it may be less applicable in batch-inspectionscenarios [7]. Thermography devices are mainly used to detect the temperature distribution on the surface of the object [8]. MRI is suitable for internal water-content detection, but not for the detection of agricultural products with extremely low water content, such as walnuts [9]. Among these, X-ray radiography is especially interesting in the field of internal quality inspection for agricultural produce, because it has good depths of X-rays and can be easily implemented inline [10]. [PERSON] et al. [11] also pointed out that X-ray technology is an appropriate alternative to the electron beam and gamma rays, and can be used in the food industry without harmful effects on human health or food quality and safety. Recently, it has been widely used in research to detect internal disorders in fruit or nuts. [PERSON] et al. [12] utilized X-ray image technology to inspect the watercore disorder in apples with a higher accuracy of 88%. [PERSON] et al. [13] and [PERSON] et al. [14] reported the internal-defects detection of apples and 'Conference' pears, achieving accuracy rates of 90% and 90.2%, respectively. [PERSON] et al. [15] and [PERSON] et al. [16] also successfully applied it to detect whether hard-shelled walnuts had become hollow and also to detect the size of the walnut kernel. Such X-ray image technology has led to promising results in real-time, non-destructive testing of internal defects in intact walnuts with shells. Over the past decade, deep-learning has played a very vital role in pattern recognition tasks, mainly because it does not require sophisticated image-processing pipelines and can automatically learn hierarchical features from the data [17]. Among various deep-learning networks, RNN often encounters the phenomenon of vanishing gradient and explosion gradient, and low computational efficiency [18]. The DBN model cannot specify the optimal classification surface between different classes, so the classification accuracy may not be as high as some discriminant model [19].