Similar Items: Exploiting Ferroelectric and Spintronic Dynamics for Neural Network Computation