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

New fixed_unigram_candidate_sampler() still requires work.

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

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

@@ -21,7 +21,7 @@ from itertools import product, \
from functools import reduce
def fixed_unigram_candidate_sampler(
def fixed_unigram_candidate_sampler_new(
true_classes: torch.Tensor,
num_repeats: torch.Tensor,
unigrams: torch.Tensor,
@@ -57,6 +57,8 @@ def fixed_unigram_candidate_sampler(
result = torch.zeros(len(indices), dtype=torch.long)
while len(indices) > 0:
print(len(indices))
candidates = torch.utils.data.WeightedRandomSampler(unigrams, len(indices))
candidates = torch.tensor(list(candidates)).view(-1, 1)
@@ -73,6 +75,7 @@ def fixed_unigram_candidate_sampler(
can_cum = cumcount(candidates[:, 0])
ind_cum = cumcount(indices[:, 1])
repeated = (can_cum > 0) & (ind_cum > 0)
# TODO: this is wrong, still requires work
mask = mask | repeated
@@ -138,7 +141,7 @@ def fixed_unigram_candidate_sampler_slow(
return torch.tensor(res)
def fixed_unigram_candidate_sampler_old(
def fixed_unigram_candidate_sampler(
true_classes: torch.Tensor,
num_repeats: torch.Tensor,
unigrams: torch.Tensor,


Loading…
Cancel
Save