Calculating the actor's and critic's losses