gradient for boltzmann machine