Nowadays, information security attacks are emerging as the main threat to network behavior. The deployment of sensor nodes in the open environment will be subjected to various kinds of DoS attacks and it needs to be analyzed. In this article, we considered two attacks namely, black hole attack and wormhole attack. The number of sensor nodes in the wireless network deployed in the network is taken as input data. Data packet drop and transmission latency are considered as two significant drawbacks of black hole and wormhole attack. Therefore, to conquer such limitations, the deep neural network based fuzzy imperialist competitive algorithm (DNN-FICA) is developed which accurately detects the presence of attacker node in the wireless network. Here, the FICA approach is utilized to optimize the weights of DNN. The simulation is conducted using MATLAB software considering the performance metrics such as detection rate, packet delivery ratio, energy consumption, network lifetime, end-to-end delay, communication overhead, throughput, and residual energy. The comparative results are carried out and the result analysis proved that the proposed DNN-FICA technique achieved greater overall performance than other compared methods.