Skip to content
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

Fix bug in CVAE example #3325

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/cvae/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def __init__(self, masked_with=-1):

def forward(self, input, target):
target = target.view(input.shape)
loss = F.binary_cross_entropy(input, target, reduction="none")
loss[target == self.masked_with] = 0
# only calculate loss on target pixels (value = -1)
loss = F.binary_cross_entropy(
input[target != self.masked_with],
target[target != self.masked_with],
reduction="none",
)
return loss.sum()


Expand Down
5 changes: 1 addition & 4 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@
"vae/ss_vae_M2.py --num-epochs=1 --enum-discrete=sequential",
"vae/vae.py --num-epochs=1",
"vae/vae_comparison.py --num-epochs=1",
pytest.param(
"cvae/main.py --num-quadrant-inputs=1 --num-epochs=1",
marks=pytest.mark.skip(reason="https://github.com/pyro-ppl/pyro/issues/3273"),
),
Comment on lines -126 to -129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you replace these four lines with just the string

"cvae/main.py --num-quadrant-inputs=1 --num-epochs=1",

The pytest.mark.skip is just to skip the test, and we now want it to run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the line for the test.

"cvae/main.py --num-quadrant-inputs=1 --num-epochs=1",
"contrib/funsor/hmm.py --num-steps=1 --truncate=10 --model=0 ",
"contrib/funsor/hmm.py --num-steps=1 --truncate=10 --model=1 ",
"contrib/funsor/hmm.py --num-steps=1 --truncate=10 --model=2 ",
Expand Down
Loading