Refactor gradient computation.
Test cross entropy.
Add more functions to python interface.
Fix debug message.