tensorflow/core/kernels/loss_test.cc
// This test checks that the dual value after update is optimal.
// At the optimum the dual value should be the opposite of the primal gradient.
// This does not hold at a point where the primal is not differentiable.
This test checks that the dual value after update is optimal.
At the optimum the dual value should be the opposite of the primal gradient.
This does not hold at a point where the primal is not differentiable.
This test checks that the dual value after update is optimal . At the optimum the dual value should be the opposite of the primal gradient . This does not hold at a point where the primal is not differentiable .
void TestComputeUpdatedDual(const DualLossUpdater &loss_updater,
                            const int num_loss_partitions, const double label,
                            const double example_weight,
                            const double current_dual, const double wx,
                            const double weighted_example_norm) {
  double new_dual = loss_updater.ComputeUpdatedDual(
      num_loss_partitions, label, example_weight, current_dual, wx,
      weighted_example_norm);
  double new_wx = wx + (new_dual - current_dual) * num_loss_partitions *
                           weighted_example_norm * example_weight;
  EXPECT_NEAR(new_dual, -loss_updater.PrimalLossDerivative(new_wx, label, 1.0),
              1e-5);
}
void TestComputeUpdatedDual ( const DualLossUpdater & loss_updater , const int num_loss_partitions , const double label , const double example_weight , const double current_dual , const double wx , const double weighted_example_norm ) { double new_dual = loss_updater . ComputeUpdatedDual ( num_loss_partitions , label , example_weight , current_dual , wx , weighted_example_norm ) ; double new_wx = wx + ( new_dual - current_dual ) * num_loss_partitions * weighted_example_norm * example_weight ; EXPECT_NEAR ( new_dual , - loss_updater . PrimalLossDerivative ( new_wx , label , 1.0 ) , 1e-5 ) ; }
This test checks that the dual value after update is optimal.
This test checks that the dual value after update is optimal .
// The primal gradient needs to be computed after the weight update.