IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Protect against endless loop.

master
Stanislaw Adaszewski 4 years ago
parent
commit
2ff358f7ef
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      src/triacontagon/sampling.py

+ 5
- 0
src/triacontagon/sampling.py View File

@@ -28,6 +28,11 @@ def fixed_unigram_candidate_sampler(
if len(num_repeats.shape) != 1:
raise ValueError('num_repeats must be 1D')
if torch.any(len(unigrams) - \
(true_classes >= 0).sum(dim=1) < \
num_repeats):
raise ValueError('Not enough classes to choose from')
num_rows = true_classes.shape[0]
print('true_classes.shape:', true_classes.shape)
# unigrams = np.array(unigrams)


Loading…
Cancel
Save