Because of retina abnormalities of diabetic patients, the most common vision‐threatening disease is diabetic retinopathy (DR). The DR diagnosis and prevention are challenging tasks as they may lead to vision loss. According to the literature analysis, the shortcomings in existing studies, such as failed to reduce the feature dimension, higher execution time, and higher computational cost, unable to tune the hyper‐parameters, such as a number of hidden layers and learning rate, more computational complexities, higher cost, and so forth, during DR classification. To tackle these problems, we proposed a deep long‐ and short‐term memory (LSTM) in a neural network with Red Fox optimization (deep LSTM‐RFO) algorithm for DR classification. The four major components involved in the proposed methods are image preprocessing, segmentation, feature extraction, and classification. At first, an adaptive histogram equalization and histogram equalization model performs the fundus image preprocessing, thereby neglecting the noise and improving the contrast level of an image. Next, an adaptive watershed segmentation model effectively segments the lesion region based on the optic disc color and size of hemorrhages. At the third stage, we have extracted statistical, intensity, color, and shape features. Finally, the single normal class with three abnormal classes such as mild non‐proliferative diabetic retinopathy, moderate NPDR, and severe NPDR are accurately classified using the deep LSTM‐RFO algorithm. Experimentally, the MESSIDOR, STARE, and DRIVE datasets are used for both training and validation. MATLAB software performs the implementation process with respect to various evaluation criteria used. However, the proposed method accomplished superior performance, such as 98.45% specificity, 96.78% sensitivity, 97.92% precision, 96.89% recall, and 97.93% F‐score results in terms of DR classification than previous methods.