{
  "scope": "Fixed scalar GAN gradient/update mechanics only; no data training, neural-network image generation, convergence, quality, or benchmark claims.",
  "environment": {
    "python": "3.10.12",
    "torch": "2.3.1+cu118",
    "device": "cpu",
    "dtype": "float64",
    "randomness": "none"
  },
  "inputs": {
    "z": [
      -1.0,
      1.0
    ],
    "real": [
      0.8,
      1.2
    ],
    "G_initial": {
      "a": 0.4,
      "c": -0.1
    },
    "D_initial": {
      "w": 1.2,
      "b": -0.3
    }
  },
  "discriminator_step": {
    "loss_definition": "mean BCEWithLogits(real, 1) + mean BCEWithLogits(fake.detach(), 0)",
    "separate_real_mean": 0.34706565920109705,
    "separate_fake_mean": 0.5323754939041144,
    "summed_loss": 0.8794411531052115,
    "before": {
      "w": 1.2,
      "b": -0.3
    },
    "grad_autograd": {
      "w": -0.27670136031806036,
      "b": 0.11049301322474825
    },
    "grad_manual_chainrule": {
      "w": -0.27670136031806036,
      "b": 0.11049301322474825
    },
    "grad_central_difference": {
      "w": -0.27670136032442727,
      "b": 0.11049301329446592
    },
    "learning_rate": 0.05,
    "expected_after": {
      "w": 1.213835068015903,
      "b": -0.3055246506612374
    },
    "actual_after": {
      "w": 1.213835068015903,
      "b": -0.3055246506612374
    },
    "G_grads_after_D_step": {
      "a": null,
      "c": null
    },
    "G_parameters_after_D_step": {
      "a": 0.4,
      "c": -0.1
    }
  },
  "generator_step": {
    "loss_definition": "mean BCEWithLogits(D(G(z)), 1), the non-saturating objective; D parameters frozen but forward path differentiable",
    "loss": 0.9571396633237046,
    "D_fixed_at": {
      "w": 1.213835068015903,
      "b": -0.3055246506612374
    },
    "before": {
      "a": 0.4,
      "c": -0.1
    },
    "grad_autograd": {
      "a": 0.13846940080558645,
      "c": -0.7276014944104432
    },
    "grad_manual_chainrule": {
      "a": 0.1384694008055865,
      "c": -0.7276014944104432
    },
    "grad_central_difference": {
      "a": 0.13846940083439563,
      "c": -0.7276014943879971
    },
    "learning_rate": 0.1,
    "expected_after": {
      "a": 0.3861530599194414,
      "c": -0.027239850558955683
    },
    "actual_after": {
      "a": 0.3861530599194414,
      "c": -0.027239850558955683
    },
    "D_grads_after_G_step": {
      "w": null,
      "b": null
    },
    "D_parameters_after_G_step": {
      "w": 1.213835068015903,
      "b": -0.3055246506612374
    }
  },
  "logit_gradient_comparison": [
    {
      "fake_logit": -8.0,
      "D_probability": 0.00033535013046647816,
      "original_minimax_G_loss_log1_minus_D": -0.00033540637289576885,
      "original_minimax_dloss_dlogit": -0.00033535013046647816,
      "non_saturating_G_loss_minus_log_D": 8.000335406372896,
      "non_saturating_dloss_dlogit": -0.9996646498695335
    },
    {
      "fake_logit": 0.0,
      "D_probability": 0.5,
      "original_minimax_G_loss_log1_minus_D": -0.6931471805599453,
      "original_minimax_dloss_dlogit": -0.5,
      "non_saturating_G_loss_minus_log_D": 0.6931471805599453,
      "non_saturating_dloss_dlogit": -0.5
    },
    {
      "fake_logit": 8.0,
      "D_probability": 0.9996646498695336,
      "original_minimax_G_loss_log1_minus_D": -8.000335406372896,
      "original_minimax_dloss_dlogit": -0.9996646498695336,
      "non_saturating_G_loss_minus_log_D": 0.00033540637289576885,
      "non_saturating_dloss_dlogit": -0.00033535013046637197
    }
  ],
  "checks": {
    "D_manual_chainrule_matches_autograd": true,
    "D_central_difference_matches_manual": true,
    "D_scalar_SGD_updates_match": true,
    "G_manual_chainrule_matches_autograd": true,
    "G_central_difference_matches_manual": true,
    "G_scalar_SGD_updates_match": true,
    "G_gradients_absent_and_params_unchanged_during_D_step": true,
    "D_grad_none_and_unchanged_by_G_step": true
  }
}
