Wireless Sensor Network (WSN) is the network of minimal expensive and tiny devices for sensing, which is known as sensors. These networks are vulnerable to various types of attacks namely black hole attack, Sybil attack and so forth. Black hole attack is the most harmful attack and also the access way for all the other types of attacks, whereas Sybil attack is a dangerous hazard to sensor networks in which sensor nodes have numerous identities. These attacks may interrupt the performance and functioning of network, which may cause harm to the network system if not properly detected. Hence, an efficacious technique is proposed for black hole and Sybil attack detection utilizing Adaptive Taylor Sail fish optimizer (Adaptive Taylor-SFO) algorithm. Firstly, WSN nodes are simulated in a network and thereafter, routing is executed by Adaptive Taylor-SFO, which is newly designed by an integration of Adaptive concept with Taylor series and Sail Fish optimizer (SFO) for selecting an optimal route by consideration of fitness measures namely, delay, energy, and distance. Finally, detection of black hole and Sybil attack is carried out by Deep stacked auto encoder. Moreover, the network classifier is tuned employing proposed Adaptive Taylor-SFO. Thus, the proposed technique effectually classified into normal, black hole and Sybil attack. Additionally, proposed technique obtained minimal delay of 19.91ms, FNR of 0.0773, FPR of 0.1026, maximal throughput of 125.73kbps and maximal PDR of 97.52%.