Commit ae14ad83 authored by Anthony Larcher's avatar Anthony Larcher
Browse files

test before refactoring

parent 524b10ee
......@@ -235,8 +235,8 @@ class Key:
with h5py.File(input_file_fame, "r") as f:
key = Key()
key.modelset = f.get("modelset")[()]
key.segset = f.get("segset")[()]
key.modelset = f["modelset"][()]
key.segset = f["segset"][()]
# if running python 3, need a conversion to unicode
if sys.version_info[0] == 3:
......
......@@ -251,13 +251,10 @@ class ArcMarginProduct(torch.nn.Module):
self.mm = math.sin(math.pi - self.m) * self.m
def forward(self, input, target=None):
if target is not None:
assert input.size()[0] == target.size()[0]
assert input.size()[1] == self.in_features
# cos(theta)
cosine = torch.nn.functional.linear(torch.nn.functional.normalize(input),
torch.nn.functional.normalize(self.weight))
cosine = torch.nn.functional.linear(torch.nn.functional.normalize(input), torch.nn.functional.normalize(self.weight))
if target == None:
return cosine * self.s
# cos(theta + m)
sine = torch.sqrt((1.0 - torch.mul(cosine, cosine)).clamp(0, 1))
phi = cosine * self.cos_m - sine * self.sin_m
......@@ -278,7 +275,7 @@ class ArcMarginProduct(torch.nn.Module):
class SoftmaxAngularProto(torch.nn.Module):
# from https://github.com/clovaai/voxceleb_trainer/blob/3bfd557fab5a3e6cd59d717f5029b3a20d22a281/loss/angleproto.py
def __init__(self, spk_count, init_w=10.0, init_b=-5.0, **kwargs):
def __init__(self, spk_count, emb_dim=256, init_w=10.0, init_b=-5.0, **kwargs):
super(SoftmaxAngularProto, self).__init__()
self.test_normalize = True
......@@ -288,7 +285,7 @@ class SoftmaxAngularProto(torch.nn.Module):
self.criterion = torch.nn.CrossEntropyLoss()
self.cce_backend = torch.nn.Sequential(OrderedDict([
("linear8", torch.nn.Linear(256, spk_count))
("linear8", torch.nn.Linear(emb_dim, spk_count))
]))
def forward(self, x, target=None):
......
This diff is collapsed.
Supports Markdown
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