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

Updates from conformer #338

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
upgrade black, reformat
  • Loading branch information
AlexandraVolokhova committed Aug 9, 2024
commit 8651fc3730fe25b21171d3abb3d55c8ab150854d
24 changes: 12 additions & 12 deletions gflownet/policy/multihead_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ def forward(self, x):
logits[indices, self.leaf_index : self.feature_index] = y_leaf
logits[indices, self.eos_index] = y_eos
elif stage == Stage.LEAF:
logits[
indices, self.feature_index : self.threshold_index
] = self.feature_head(batch)
logits[indices, self.feature_index : self.threshold_index] = (
self.feature_head(batch)
)
else:
ks = [Tree.find_active(state) for state in states]
feature_index = torch.Tensor(
Expand All @@ -374,9 +374,9 @@ def forward(self, x):
if self.continuous:
logits[indices, (self.eos_index + 1) :] = head_output
else:
logits[
indices, self.threshold_index : self.operator_index
] = head_output
logits[indices, self.threshold_index : self.operator_index] = (
head_output
)
elif stage == Stage.THRESHOLD:
threshold = torch.Tensor(
[
Expand Down Expand Up @@ -464,14 +464,14 @@ def forward(self, x):
)

if stage == Stage.COMPLETE:
logits[
indices, self.operator_index : self.eos_index
] = self.complete_stage_head(batch)
logits[indices, self.operator_index : self.eos_index] = (
self.complete_stage_head(batch)
)
logits[indices, self.eos_index] = 1.0
elif stage == Stage.LEAF:
logits[
indices, self.leaf_index : self.feature_index
] = self.leaf_stage_head(batch)
logits[indices, self.leaf_index : self.feature_index] = (
self.leaf_stage_head(batch)
)
elif stage == Stage.FEATURE:
logits[indices, self.feature_index : self.threshold_index] = 1.0
elif stage == Stage.THRESHOLD:
Expand Down
6 changes: 3 additions & 3 deletions gflownet/utils/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,9 @@ def get_masks_forward(
masks_invalid_actions_forward_parents[parents_indices == -1] = self.source[
"mask_forward"
]
masks_invalid_actions_forward_parents[
parents_indices != -1
] = masks_invalid_actions_forward[parents_indices[parents_indices != -1]]
masks_invalid_actions_forward_parents[parents_indices != -1] = (
masks_invalid_actions_forward[parents_indices[parents_indices != -1]]
)
return masks_invalid_actions_forward_parents
return masks_invalid_actions_forward

Expand Down
Loading