Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
OpenFold
Commits
fb785094
Commit
fb785094
authored
Oct 08, 2021
by
Gustaf Ahdritz
Browse files
Remove Python 3.9-only math function
parent
3bb47f89
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
openfold/model/primitives.py
openfold/model/primitives.py
+8
-2
No files found.
openfold/model/primitives.py
View file @
fb785094
...
@@ -27,10 +27,16 @@ from openfold.utils.tensor_utils import (
...
@@ -27,10 +27,16 @@ from openfold.utils.tensor_utils import (
)
)
def
_prod
(
nums
):
out
=
1
for
n
in
nums
:
out
=
out
*
n
return
nums
def
_calculate_fan
(
shape
,
fan
=
"fan_in"
):
def
_calculate_fan
(
shape
,
fan
=
"fan_in"
):
i
=
shape
[
0
]
i
=
shape
[
0
]
o
=
shape
[
1
]
o
=
shape
[
1
]
prod
=
math
.
prod
(
shape
[:
2
])
prod
=
_
prod
(
shape
[:
2
])
fan_in
=
prod
*
i
fan_in
=
prod
*
i
fan_out
=
prod
*
o
fan_out
=
prod
*
o
...
@@ -53,7 +59,7 @@ def trunc_normal_init_(weights, scale=1.0, fan="fan_in"):
...
@@ -53,7 +59,7 @@ def trunc_normal_init_(weights, scale=1.0, fan="fan_in"):
a
=
-
2
a
=
-
2
b
=
2
b
=
2
std
=
math
.
sqrt
(
scale
)
/
truncnorm
.
std
(
a
=
a
,
b
=
b
,
loc
=
0
,
scale
=
1
)
std
=
math
.
sqrt
(
scale
)
/
truncnorm
.
std
(
a
=
a
,
b
=
b
,
loc
=
0
,
scale
=
1
)
size
=
math
.
prod
(
shape
)
size
=
_
prod
(
shape
)
samples
=
truncnorm
.
rvs
(
a
=
a
,
b
=
b
,
loc
=
0
,
scale
=
std
,
size
=
size
)
samples
=
truncnorm
.
rvs
(
a
=
a
,
b
=
b
,
loc
=
0
,
scale
=
std
,
size
=
size
)
samples
=
np
.
reshape
(
samples
,
shape
)
samples
=
np
.
reshape
(
samples
,
shape
)
with
torch
.
no_grad
():
with
torch
.
no_grad
():
...
...
Write
Preview
Markdown
is supported
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