Dangerous insects are a significant risk to the global agricultural industry, threatening food security, economic stability, and crop quality. This study investigates the impact of multiple optimization algorithms within transfer learning, employing EfficientNet models for the classification of agricultural insects. The explored optimization algorithms include Adam, Adamax, AdamW, RMSprop, and SGD, while utilizing the EfficientNetB0, EfficientNetB3, EfficientNetB5, and EfficientNetB7 architectures. Experimental results show notable performance differences between optimization algorithms across all EfficiencyNet models in the study. Among the measured metrics are precision, recall, f1-score, accuracy, and loss, the AdamW optimizer consistently demonstrates superior performance compared to other algorithms. The findings underscore the critical influence of optimization algorithms in enhancing classification accuracy and convergence within transfer learning scenarios. Additionally, the study employs various visualization techniques, such as Gradient-weighted Class Activation Mapping (Grad-CAM) to enhance the interpretation of the image classification model’s results. By focusing on these methodologies, this research aims to improve the model’s performance, optimize its capabilities, and ultimately contribute to effective pest management strategies in agriculture, safeguarding crop yields, farmer livelihoods, and global food security.