mirror of
https://github.com/karpathy/nanochat.git
synced 2025-12-06 04:12:13 +00:00
Gracefully handle stop > dataset_size with warning
This commit is contained in:
parent
cd782a1977
commit
85e49943ed
|
|
@ -36,12 +36,14 @@ class Task:
|
||||||
start = self.start
|
start = self.start
|
||||||
if self.stop is not None:
|
if self.stop is not None:
|
||||||
num_ex = self.num_examples()
|
num_ex = self.num_examples()
|
||||||
|
stop = min(self.stop, num_ex) # Gracefully cap at dataset size
|
||||||
if self.stop > num_ex:
|
if self.stop > num_ex:
|
||||||
raise ValueError(
|
import warnings
|
||||||
|
warnings.warn(
|
||||||
f"Stop parameter ({self.stop}) exceeds dataset size ({num_ex}). "
|
f"Stop parameter ({self.stop}) exceeds dataset size ({num_ex}). "
|
||||||
f"Please use stop <= {num_ex} or remove the stop parameter to use the full dataset."
|
f"Using {num_ex} examples instead.",
|
||||||
|
UserWarning
|
||||||
)
|
)
|
||||||
stop = self.stop
|
|
||||||
else:
|
else:
|
||||||
stop = self.num_examples()
|
stop = self.num_examples()
|
||||||
step = self.step
|
step = self.step
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user