fix a bug in Mem[read|write]Engine.  further refinement of rbm example