Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Anthony Larcher
sidekit
Commits
ae14ad83
Commit
ae14ad83
authored
Apr 05, 2021
by
Anthony Larcher
Browse files
test before refactoring
parent
524b10ee
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
bosaris/key.py
View file @
ae14ad83
...
...
@@ -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
:
...
...
nnet/loss.py
View file @
ae14ad83
...
...
@@ -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
):
...
...
nnet/xvector.py
View file @
ae14ad83
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment