By the Neyman-Pearson Lemma and the Likelihood-Ratio Trick, the test statistic with the optimal power for a test of H 0 : p(x|θ 0 ) and H 1 : p mix (x|S c ) can be found by optimizing the binary cross-entropy:
L BXE (φ|S c , θ 0 ) = −E (y,x∼p(x|θ 0 ),p mix (x|Sc) [(y log s φ (x) + (1 − y) log(1 − s φ (x))],(8)
where samples from θ 0 are labeled y = 0 and samples from the mixture of alternatives are labelled y = 1. To optimize the global power from Equation 6 in a likelihood-free way we can now average over S c and θ 0 to define a global loss L(φ)
L(φ) = E Sc,θ 0 [L BXE (φ|S c , θ 0 )](9)
given choice of densities p(θ alt |S c ), p(S c |θ 0 ), p(θ 0 ). The final optimization procedure is simple: for each minibatch, sample θ 0 and a random set of alternatives from θ alt from a random surface S c (θ 0 ), evaluate the neural network on **data** x ∼ p(x|θ i ) and compute the average of the binary cross-entropy losses for each alternative, where samples from θ 0 are labeled y = 0 and any samples from any θ alt are labelled y = 1. With such a procedure and average loss definition, the parameters φ can be optimized via standard stochastic gradient descent. The algorithm is summarized in Algorithm 1.