Skip to content
GitLab
Menu
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
575a86bc
Commit
575a86bc
authored
Jun 10, 2021
by
Anthony Larcher
Browse files
doc
parent
dc71e2b2
Changes
1
Show whitespace changes
Inline
Side-by-side
nnet/loss.py
View file @
575a86bc
...
...
@@ -251,6 +251,11 @@ class ArcMarginProduct(torch.nn.Module):
self
.
mm
=
math
.
sin
(
math
.
pi
-
self
.
m
)
*
self
.
m
def
change_params
(
self
,
s
=
None
,
m
=
None
):
"""
:param s:
:param m:
"""
if
s
is
None
:
s
=
self
.
s
if
m
is
None
:
...
...
@@ -263,8 +268,15 @@ class ArcMarginProduct(torch.nn.Module):
self
.
mm
=
math
.
sin
(
math
.
pi
-
self
.
m
)
*
self
.
m
def
forward
(
self
,
input
,
target
=
None
):
"""
:param input:
:param target:
:return:
"""
# 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)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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