Commit 7f09fefa authored by Anthony Larcher's avatar Anthony Larcher
Browse files

correct extract embeddings

parent 73c2d923
......@@ -147,9 +147,10 @@ class SideSampler(torch.utils.data.Sampler):
self.index_iterator[idx] = self.labels_to_indices[value][self.segment_cursors[value]]
self.segment_cursors[value] += 1
self.index_iterator = numpy.repeat(self.index_iterator, self.num_replicas)
#self.index_iterator = self.index_iterator.reshape(-1, self.num_process * self.examples_per_speaker)[:, self.rank * self.examples_per_speaker:(self.rank + 1) * self.examples_per_speaker].flatten()
self.index_iterator = self.index_iterator.reshape(-1, self.num_process * self.examples_per_speaker * self.num_replicas)[:, self.rank * self.examples_per_speaker * self.num_replicas:(self.rank + 1) * self.examples_per_speaker * self.num_replicas].flatten()
print(f"num_replicas = {self.num_replicas}")
#self.index_iterator = numpy.repeat(self.index_iterator, self.num_replicas)
self.index_iterator = self.index_iterator.reshape(-1, self.num_process * self.examples_per_speaker)[:, self.rank * self.examples_per_speaker:(self.rank + 1) * self.examples_per_speaker].flatten()
#self.index_iterator = self.index_iterator.reshape(-1, self.num_process * self.examples_per_speaker * self.num_replicas)[:, self.rank * self.examples_per_speaker * self.num_replicas:(self.rank + 1) * self.examples_per_speaker * self.num_replicas].flatten()
return iter(self.index_iterator)
......
......@@ -1675,9 +1675,12 @@ def extract_embeddings(idmap_name,
_, vec = model(x=td.to(device), is_eval=True)
embed.append(vec.detach().cpu())
modelset += [mod,] * data.shape[0]
segset += [seg,] * data.shape[0]
starts += [numpy.arange(start, start + vec.shape[0] * win_shift , win_shift),]
#modelset.extend([mod,] * data.shape[0])
modelset.extend(mod * data.shape[0])
segset.extend(seg * data.shape[0])
starts.extend(numpy.arange(start, start + vec.shape[0] * win_shift , win_shift))
embeddings = StatServer()
embeddings.modelset = numpy.array(modelset).astype('>U')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment