Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PSTAL étudiant.e.s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carlos Ramisch
PSTAL étudiant.e.s
Commits
db3be55e
Commit
db3be55e
authored
4 months ago
by
Carlos Ramisch
Browse files
Options
Downloads
Patches
Plain Diff
Add cm6 code
parent
5867c799
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cm-code/biaffine.py
+21
-0
21 additions, 0 deletions
cm-code/biaffine.py
with
21 additions
and
0 deletions
cm-code/biaffine.py
0 → 100755
+
21
−
0
View file @
db3be55e
#!/usr/bin/env python3
import
numpy
as
np
n
=
4
d
=
10
Hhead
=
np
.
random
.
rand
(
n
,
d
)
# head vectors as rows
Hdep
=
np
.
random
.
rand
(
n
,
d
)
# dep vectors as rows
Uarc
=
np
.
random
.
rand
(
d
,
d
)
# biaffine intermediate matrix
uarc
=
np
.
random
.
rand
(
d
,
1
)
# biaffine bias
Sarc_original
=
Hhead
@
Uarc
@
Hdep
.
T
+
Hhead
@
uarc
#print(Sarc_original)
ubias
=
np
.
vstack
((
Uarc
.
T
,
uarc
.
T
))
# Uarc transposition not in paper, but not important since learned
Hdepext
=
np
.
hstack
((
Hdep
,
np
.
ones
((
n
,
1
))))
Sarc_simple
=
((
Hdepext
@
ubias
)
@
Hhead
.
T
).
T
# final transpose: dependents as columns
#print(Sarc_simple)
print
(
f
"
Original and simplified versions identical:
{
np
.
allclose
(
Sarc_original
,
Sarc_simple
)
}
"
)
# quality up to tolerance
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment