The derivatives of the log prob
If unit i is on:
If unit i is off:
In both cases we get: