Variational And Dynamical Perspectives On Learning And Optimization