Skip to content

Commit

Permalink
handle context/multimode mask input smarter
Browse files Browse the repository at this point in the history
  • Loading branch information
landoskape committed May 10, 2024
1 parent b33e876 commit 3ef2888
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions dominoes/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@ def train(nets, optimizers, dataset, **parameters):
# get input for batch
input = batch["input"]

# add context inputs for batch if requested (use *context_inputs for consistent handling)
context_inputs = []
if "context" in batch:
context_inputs.append(batch["context"])
if "multimode" in batch:
context_inputs.append(batch["multimode"])

# get current max output for batch
max_output = batch.get("max_output", max_possible_output)

# get kwargs for forward pass
net_kwargs = dict(
mask=batch.get("mask", None),
context_mask=batch.get("context_mask", None),
mm_mask=batch.get("mm_mask", None),
init=batch.get("init", None),
temperature=temperature,
thompson=thompson,
max_output=max_output,
)

# add context inputs for batch if requested (use *context_inputs for consistent handling)
context_inputs = []
if "context" in batch:
context_inputs.append(batch["context"])
net_kwargs["context_mask"] = batch.get("context_mask", None)
if "multimode" in batch:
context_inputs.append(batch["multimode"])
net_kwargs["mm_mask"] = batch.get("mm_mask", None)

# zero gradients
for opt in optimizers:
opt.zero_grad()
Expand Down

0 comments on commit 3ef2888

Please sign in to comment.