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

internal. #474

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 5 additions & 3 deletions seqio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def load(self, split, shuffle_files, seed=None, shard_info=None):
split = self._map_split(split)
read_config = self.read_config
read_config.input_context = (
tf.distribute.InputContext(
tf.distribute.InputContext( # pylint: disable=g-long-ternary
num_input_pipelines=shard_info.num_shards,
input_pipeline_id=shard_info.index,
)
Expand Down Expand Up @@ -1103,6 +1103,7 @@ def mixing_rate_num_examples(
scale: float = 1.0,
temperature: float = 1.0,
fallback_to_num_input_examples: bool = True,
split: str = "train",
) -> float:
"""Mixing rate based on the number of examples for the task's 'train' split.

Expand All @@ -1115,13 +1116,14 @@ def mixing_rate_num_examples(
fallback_to_num_input_examples: whether to fallback to using the number of
input examples when the Task is not cached. Otherwise, an error will be
raised.
split: the split to look at for cached stats.

Returns:
The mixing rate for this task.
"""

if task.cache_dir or not fallback_to_num_input_examples:
ret = task.get_cached_stats("train")["examples"]
ret = task.get_cached_stats(split)["examples"]
else:
logging.warning(
(
Expand All @@ -1130,7 +1132,7 @@ def mixing_rate_num_examples(
),
task.name,
)
ret = task.num_input_examples("train")
ret = task.num_input_examples(split)

ret *= scale
if maximum:
Expand Down