fix a bug in sum-of-squares, fix some bugs in the SW.  rbm::train completes with verify==true

Change-Id: Ic71bdd6c348ebe96f4991e77dc7b69f9be668c1b