Analyzing The Dynamics Of Biological And Artificial Neural Networks With Applications To Machine Learning