Skip to content

fix(cgan): make density output activation configurable#70

Merged
SoheylM merged 3 commits into
mainfrom
codex/address-cgan-issues
Jun 4, 2026
Merged

fix(cgan): make density output activation configurable#70
SoheylM merged 3 commits into
mainfrom
codex/address-cgan-issues

Conversation

@SoheylM

@SoheylM SoheylM commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a backward-compatible tanh|sigmoid generator output activation option for cgan_2d and cgan_cnn_2d
  • keep tanh as the default so existing W&B checkpoints load with their original convention
  • let new density-field runs opt into native [0, 1] sigmoid outputs and document the flag

Fixes #69

Tests

  • conda run -n engibench pytest -q
  • conda run -n engibench ruff check engiopt/cgan_2d/cgan_2d.py engiopt/cgan_2d/evaluate_cgan_2d.py engiopt/cgan_cnn_2d/cgan_cnn_2d.py engiopt/cgan_cnn_2d/evaluate_cgan_cnn_2d.py tests/test_cgan_output_activation.py
  • conda run -n engibench ruff format --check engiopt/cgan_2d/cgan_2d.py engiopt/cgan_2d/evaluate_cgan_2d.py engiopt/cgan_cnn_2d/cgan_cnn_2d.py engiopt/cgan_cnn_2d/evaluate_cgan_cnn_2d.py tests/test_cgan_output_activation.py

@SoheylM

SoheylM commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Adding the qualitative Beams2D sanity-check figure for this cGAN output-activation change.

cGAN 2D 50-epoch Beams2D reference comparison

This is a short local smoke test, not a final benchmark: cgan_2d was trained for 50 epochs on 2048 Beams2D training samples and compared against optimized test references under the same conditions. The main motivation for this PR shows up clearly: the legacy tanh head still emits invalid negative raw densities (raw_neg=27.7% here), while the opt-in sigmoid head emits native [0, 1] densities (raw_neg=0.0%) and modestly improves this quick reference MAE (0.191 vs 0.210).

@g-braeunlich g-braeunlich removed their assignment May 27, 2026
Comment thread tests/test_cgan_output_activation.py Outdated
Comment thread engiopt/cgan_2d/cgan_2d.py
Comment thread engiopt/cgan_cnn_2d/cgan_cnn_2d.py
@SoheylM SoheylM merged commit fb8fb12 into main Jun 4, 2026
3 checks passed
@SoheylM SoheylM deleted the codex/address-cgan-issues branch June 4, 2026 08:31
AnnaDelbeke pushed a commit to AnnaDelbeke/EngiOpt that referenced this pull request Jun 26, 2026
fix(cgan): make density output activation configurable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align cGAN output activation with EngiBench density range

3 participants