The combination of computer algorithms to diagnose clinical images has attracted more and more attention. This research aims to improve the efficiency of gastric cancer (GC) diagnosis, so deep learning (DL) algorithms are tentatively used to assist doctors in the diagnosis of gastric cancer. In the experiment, the collected 3591 gastroscopic images were divided into network training set and experimental verification test set. The lesion samples in the image are all marked by many endoscopists with many years of clinical experience. In order to improve the experimental effect, 5261 endoscopic images were obtained by expanding the training set. Then the obtained training set is input into the convolutional neural network (CNN) for training, and finally get the algorithm model DLU‐Net. By inputting 598 test set samples into the CNN constructed in this paper, five results such as advanced GC, early GC, precancerous lesions, normal and benign lesions can be identified and output, with a total accuracy of 94.1%. It can be concluded that the DL algorithm model constructed in this paper can effectively identify the staging characteristics of cancer as well as gastroscopic images, greatly improve efficiency, and effectively assist physicians in the diagnosis of GC under gastroscopy.