2 loops of sgd