Today, computer networks monitor and manage critical infrastructures such as banking, transportation, commerce, and telecommunications. As a result, securing these systems against planned attacks is crucial. Most of these attacks exploit software errors and security vulnerabilities in the target system. It is impossible to eliminate software errors, so all software has security gaps. This study aims to detect intrusion in computer networks using the improved artificial neural network approach based on the artificial bee colony algorithm. The NSL-KDD dataset is used to test and evaluate the proposed model. The training set includes 24 types of attacks, while the test set includes 14 distinct attacks that do not exist in the training set. The results proved that the proposed method is more efficient than other methods in all cases where the data have a different observation probability. Although in some cases, our proposed method is less efficient than the basic method, in most cases, it is one of the best methods available. After selecting important features and deleting irrelevant data, the power and accuracy of the classification in the proposed method increase significantly.