Viral and bacterial infection diseases are the most common things caused by microbes. Infection diseases are serious issues because of the growth of COVID‐19. Because of the current living situation, clinical pathogens are difficult to identify. Therefore, biosensors have been widely utilized to sense the biomolecules relevant to viruses and bacteria. The biosensors observe the nanoparticles from the pathogens and help improve the infection analysis. The sensor information is processed using machine learning techniques because it consists of several learning patterns. However, the existing methods have multi‐objective optimization problems while analysing the changes in the nanoparticles. This work utilizes a mayfly optimized convoluted neural network (MOCNN) to overcome this research issue. The grid uses the fully convolution layer that processes the extracted biosensor features to determine the infections. The network performance is optimized by applying the exploitation and exploration properties of nuptial dance that help to escape from the local optima solutions. The effective utilization of the optimized training patterns improves the convergence speed and convergence rate compared to traditional methods. From the results, MOCNN ensures 98.97% accuracy, 0.388 error rate, and 0.322833 convergence rate on various iterations with different learning rates.