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

nit: added default value for log_reward_clip_min in abstract base class #158

Merged
merged 1 commit into from
Feb 19, 2024
Merged
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
3 changes: 2 additions & 1 deletion src/gfn/gflownet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class GFlowNet(ABC, nn.Module, Generic[TrainingSampleType]):

A formal definition of GFlowNets is given in Sec. 3 of [GFlowNet Foundations](https://arxiv.org/pdf/2111.09266).
"""
log_reward_clip_min = float("-inf") # Default off.

@abstractmethod
def sample_trajectories(
Expand Down Expand Up @@ -214,7 +215,7 @@ def get_trajectories_scores(
total_log_pb_trajectories = log_pb_trajectories.sum(dim=0)

log_rewards = trajectories.log_rewards
# TODO: log_reward_clip_min isn't defined in base (#155).

if math.isfinite(self.log_reward_clip_min) and log_rewards is not None:
log_rewards = log_rewards.clamp_min(self.log_reward_clip_min)

Expand Down
Loading