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
FAST-RNNT
Commits
9ac065f0
"vscode:/vscode.git/clone" did not exist on "4cea74c73b2e0981aadfefb3a00e8186d065c897"
Commit
9ac065f0
authored
Jul 29, 2021
by
Daniel Povey
Browse files
Some bug fixes, testing..
parent
1ad556dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
torch_mutual_information/mutual_information.py
torch_mutual_information/mutual_information.py
+1
-1
torch_mutual_information/mutual_information_test.py
torch_mutual_information/mutual_information_test.py
+13
-10
No files found.
torch_mutual_information/mutual_information.py
View file @
9ac065f0
...
@@ -189,7 +189,7 @@ def mutual_information_recursion(px, py, boundary=None):
...
@@ -189,7 +189,7 @@ def mutual_information_recursion(px, py, boundary=None):
assert
px
.
dtype
==
py
.
dtype
assert
px
.
dtype
==
py
.
dtype
(
B
,
S
,
T
)
=
px
.
shape
(
B
,
S
,
T
)
=
px
.
shape
if
boundary
is
not
None
:
if
boundary
is
not
None
:
assert
boundary
.
dtype
==
torch
.
LongTensor
assert
boundary
.
dtype
==
torch
.
int64
assert
boundary
.
shape
==
(
B
,
4
)
assert
boundary
.
shape
==
(
B
,
4
)
...
...
torch_mutual_information/mutual_information_test.py
View file @
9ac065f0
...
@@ -9,16 +9,19 @@ from torch_mutual_information import mutual_information_recursion
...
@@ -9,16 +9,19 @@ from torch_mutual_information import mutual_information_recursion
def
test_mutual_information_basic
():
def
test_mutual_information_basic
():
print
(
"Running test_mutual_information_basic()"
)
print
(
"Running test_mutual_information_basic()"
)
for
dtype
in
[
torch
.
float32
,
torch
.
float64
]:
for
dtype
in
[
torch
.
float32
,
torch
.
float64
]:
B
=
2
for
device
in
[
torch
.
device
(
'cpu'
),
torch
.
device
(
'cuda:0'
)
]:
S
=
4
print
(
"dtype = "
,
dtype
,
", device = "
,
device
)
T
=
5
B
=
2
px
=
torch
.
zeros
(
B
,
S
,
T
+
1
)
# log of an odds ratio
S
=
4
py
=
torch
.
zeros
(
B
,
S
+
1
,
T
)
# log of an odds ratio
T
=
5
boundary
=
torch
.
tensor
([
0
,
0
,
S
,
T
],
dtype
=
torch
.
int64
).
unsqueeze
(
0
).
expand
(
B
,
4
).
to
(
device
)
px
=
torch
.
zeros
(
B
,
S
,
T
+
1
).
to
(
device
)
# log of an odds ratio
m
=
mutual_information_recursion
(
px
,
py
)
py
=
torch
.
zeros
(
B
,
S
+
1
,
T
).
to
(
device
)
# log of an odds ratio
print
(
"m = "
,
m
)
m
=
mutual_information_recursion
(
px
,
py
,
boundary
)
print
(
"m = "
,
m
)
print
(
"exp(m) = "
,
m
.
exp
())
...
...
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