TLDR: This research paper investigates the use of Particle Swarm Optimization (PSO) and Whale Optimization Algorithm (WOA) to optimize Convolutional Neural Network (CNN) hyperparameters for automated soil image classification. The study, which classified four soil types (Alluvial, Black, Clay, Red), found that the PSO-CNN model achieved a higher classification accuracy of 96% compared to the WOA-CNN model’s 94%. This demonstrates the effectiveness of metaheuristic algorithms in enhancing AI models for critical applications in agriculture and environmental management.
Understanding soil types is crucial for effective land management, boosting agricultural output, and addressing environmental challenges. Traditionally, soil classification has relied on time-consuming and costly laboratory analyses. However, with the rapid advancements in artificial intelligence (AI), machine learning (ML), and deep learning (DL), automated soil classification has become a significant area of focus.
Convolutional Neural Networks (CNNs) have emerged as powerful tools for image-based classification, making them highly suitable for analyzing soil images. Yet, the performance of CNNs heavily depends on the careful selection of their ‘hyperparameters’ – settings like learning rate, filter size, and the number of layers. Manually tuning these or using basic search methods can be inefficient and computationally expensive.
To overcome this hurdle, researchers are turning to metaheuristic optimization algorithms. A recent study explored the effectiveness of two such algorithms: the Whale Optimization Algorithm (WOA) and Particle Swarm Optimization (PSO). These algorithms, inspired by natural phenomena like the hunting behavior of humpback whales and the collective intelligence of bird flocks, offer robust global search capabilities to fine-tune CNN hyperparameters efficiently.
The Approach
The research involved building an intelligent model to classify four main soil types: Alluvial, Black, Clay, and Red. A CNN network was designed, and its hyperparameters were optimized using both the WOA and PSO algorithms. The dataset used for this study consisted of 340 soil images sourced from Kaggle, which were preprocessed by resizing them to a uniform 300×300 pixels and organizing them into batches. Labels were encoded, and pixel values were normalized to ensure compatibility and improve model stability.
The CNN architecture was kept lean to facilitate hyperparameter search, focusing on four key parameters: the number of convolutional filters (Nf), the number of dense units (Nd), the dropout rate (p), and the learning rate (η) for the Adam optimizer. The network processed RGB soil images through a series of convolutional, pooling, flattening, and dense layers, culminating in a softmax activation for classification.
How the Optimization Algorithms Worked
The **PSO-CNN model** simulates the social behavior of bird flocks. It uses five ‘particles,’ each representing a different set of hyperparameter configurations. These particles adjust their ‘velocities’ and ‘positions’ based on their own best performance (personal best) and the best performance found by any particle in the swarm (global best). This iterative process, conducted over five iterations with rapid 5-epoch CNN training for fitness evaluation, helps balance exploration and exploitation of the hyperparameter space.
Similarly, the **WOA-CNN model** mimics the hunting strategy of whales. It starts with a population of five ‘whale solutions,’ each a unique set of CNN hyperparameters. Whales update their positions using three behavioral patterns: shrinking encircling (moving towards the best solution found so far), spiral bubble-net feeding (following a logarithmic spiral path), and exploration (searching randomly). This algorithm also continuously tracks and updates the best-performing whale over 10 optimization iterations, with each whale undergoing 5-epoch training sessions for fitness calculation.
Also Read:
- High-Resolution AI: Panoptic Segmentation for Environmental UAV Images of Litter Beaches
- Advanced Neural Networks for Reliable Train Speed Prediction
Key Findings
Both WOA-CNN and PSO-CNN models demonstrated strong performance in classifying soil types. The experimental results showed that the WOA-CNN model achieved an accuracy of 94%, while the PSO-CNN model slightly outperformed it with an accuracy of 96%. The PSO-CNN model consistently showed better results across various evaluation metrics, including precision, recall, and F1-score, particularly for Black and Red soil types. This suggests that PSO was more effective in exploring and exploiting the hyperparameter search space, leading to superior optimization.
The study concludes that integrating swarm intelligence algorithms with CNNs offers a powerful framework for automated soil classification. This approach reduces the reliance on manual feature engineering and expensive laboratory analyses, contributing significantly to precision agriculture, sustainable land management, and environmental monitoring. Future research could explore larger datasets, hybrid optimization techniques, and transfer learning to further enhance model generalization and scalability.
For more detailed information, you can read the full research paper here.


