Solved by phan_phan in post #2 
              
              
                It’s because you should have separated the computations for each element of you batch! 
Here, instead of: 
loss_d_out = (loss_d_1 + loss_d_2) / 2
weight = weight_0 - l_rate * loss_d_out * in_mean
bias = bias_0 - l_rate * loss_d_out

it should rather be: 
weight = weight_0 - l_rate * (loss_d_1 * in_1…