Detecting attacks in Wireless Sensor Networks (WSNs) is vital to protect data integrity, prevent unauthorized access, ensure reliable communication, and protect resource-constrained nodes from threats like spoofing and routing attacks in hostile environments. Since WSNs are typically deployed in unattended and resource-limited settings, they are highly susceptible to both external adversaries and internal compromised nodes. Effective identification of malicious activities in WSNs safeguards data accuracy, enhances operational reliability, and supports extended system lifespan. This is particularly important in mission-critical applications such as military surveillance, disaster response, and industrial monitoring, where undetected attacks could cause catastrophic failures. However, prevailing methods often fail to attain high detection efficiency due to noisy inputs, dimensional complexity, and high false positives. High-dimensional sensor data often contains redundant or irrelevant features, which makes traditional machine learning models prone to overfitting and misclassification. Thus, an effective model, termed ResNeXT_Tri-Error Index (ResNeXT_TEI), is established for attack detection in WSNs. Initially, WSN is simulated, and then, the input network log data is applied to data normalization. The data normalization is performed by using median normalization for transforming the data into a consistent format. After that, feature selection is done by utilizing the Fisher score. Lastly, attack detection is accomplished by the introduced ResNeXT_TEI. In addition, TEI is developed by the combination of Mean Squared Logarithmic Error (MSLE), Mean Bias Error (MBE), and Mean Absolute Error (MAE). Furthermore, the developed ResNeXT_TEI achieved a superior accuracy, True Positive Rate (TPR), and True Negative Rate (TNR) of 96.690%, 97.368%, and 96.118%, respectively.