Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
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
6 changes: 6 additions & 0 deletions torchFastText/torchFastText.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ def build(
self.num_classes = len(
np.unique(y_train)
) # Be sure that y_train contains all the classes !

if np.max(y_train) >= self.num_classes:
raise ValueError(
f"y_train must contain values between 0 and {self.num_classes - 1}. Make sure that np.max(y_train) == len(np.unique(y_train))-1."
)

else:
if self.num_classes is None:
raise ValueError(
Expand Down