-
Notifications
You must be signed in to change notification settings - Fork 6
Final version of the PixelCNN++ implementation #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…in pixel_cnn_pp_2d.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a complete PixelCNN++ implementation for 2D design generation, based on the OpenAI TensorFlow implementation and Lucas Caccia's PyTorch port. The implementation includes training, sampling, and evaluation capabilities for conditional generative modeling of engineering designs.
Key Changes
- Adds a full PixelCNN++ 2D model implementation with shifted convolutions, gated residual blocks, and discretized mixture of logistics loss
- Provides an evaluation script for model assessment using wandb artifact management
- Accidentally modifies cgan_cnn_2d.py to reduce training epochs from 200 to 2 (likely a debugging change)
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| engiopt/pixel_cnn_pp_2d/pixel_cnn_pp_2d.py | Complete PixelCNN++ implementation including model architecture (Nin, GatedResnet, shifted convolution layers), loss functions, sampling logic, and training loop with wandb integration |
| engiopt/pixel_cnn_pp_2d/evaluate_pixel_cnn_pp_2d.py | Evaluation script that loads trained models from wandb artifacts, generates samples with specified conditions, and computes performance metrics |
| engiopt/pixel_cnn_pp_2d/init.py | Empty init file for the new module |
| engiopt/cgan_cnn_2d/cgan_cnn_2d.py | Reduces default training epochs from 200 to 2 (appears to be an unintended debugging change) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| shuffle=True, | ||
| ) | ||
|
|
||
| # Optimzer |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "Optimzer" should be "Optimizer".
engiopt/cgan_cnn_2d/cgan_cnn_2d.py
Outdated
|
|
||
| # Algorithm specific | ||
| n_epochs: int = 200 | ||
| n_epochs: int = 2 |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The n_epochs default value has been changed from 200 to 2. This appears to be a debugging value that was accidentally left in the code. Training for only 2 epochs is insufficient for model convergence and will result in poor performance. This should be reverted to the original value of 200 or another appropriate value for production use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with copilot @JonasETHZ
ffelten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a quick pass. I think copilot has some good points, also ruff will probably complain
engiopt/cgan_cnn_2d/cgan_cnn_2d.py
Outdated
|
|
||
| # Algorithm specific | ||
| n_epochs: int = 200 | ||
| n_epochs: int = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with copilot @JonasETHZ
|
|
||
| def sample_from_discretized_mix_logistic(l: th.Tensor, nr_mix: int) -> th.Tensor: | ||
| """Sample from a discretized mixture of logistic distributions.""" | ||
| # Tensorflow ordering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some Tensorflow comments left here and there
|
|
||
| # unpack parameters | ||
| logit_probs = l[:, :, :, :nr_mix] # mixture probabilities | ||
| l = l[:, :, :, nr_mix:].contiguous().view([*xs, nr_mix * 2]) # for mean, scale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very cryptic to me, a comment would help understanding what's going on here.
|
@ffelten I see that this PR is ready to be merged and that you have approved. Can you confirm that we are all good and that I can merge this? If this is good to go then the only thing I see that needs updating is the README.md to add a row to the table noting the implementation in the library. |
I think it is good to go. Although a bit complex due to the masking ops and slow inference, it is a simple example of an AutoRegressive model--will be a good addition for educational purposes. |
No description provided.