Connectome, the complete wiring diagram of the nervous system of an organism, is the biological substrate of the mind. While biological neural networks are crucial to the understanding of neural computation mechanisms, recent artificial neural networks (ANNs) have been developed independently from the study of real neural networks. Computational scientists are searching for various ANN architectures to improve machine learning since the architectures are associated with the accuracy of ANNs. A recent study used the hermaphrodite Caenorhabditis elegans (C. elegans) connectome for image classification tasks, where the edge directions were changed to construct a directed acyclic graph (DAG). In this study, we used the whole-animal connectomes of C. elegans hermaphrodite and male to construct a DAG that preserves the chief information flow in the connectomes and trained them for image classification of MNIST and fashion-MNIST datasets. The connectome-inspired neural networks exhibited over 99.5% and 92.6% of accuracy for MNIST and fashion-MNIST datasets, respectively, which increased from the previous study. Together, we conclude that realistic biological neural networks provide the basis of a plausible ANN architecture. This study suggests that biological networks can provide new inspiration to improve artificial intelligences (AIs).