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
2ec4b08e
"vscode:/vscode.git/clone" did not exist on "f06d522c750e2bc09ee1a5393736f03d26a82480"
Commit
2ec4b08e
authored
Jul 16, 2021
by
Daniel Povey
Browse files
Testing of the dim parameter and reshaping capabilities
parent
c288e95b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
setup.py
setup.py
+1
-1
torch_learned_nonlin/learned_nonlin_test.py
torch_learned_nonlin/learned_nonlin_test.py
+13
-0
No files found.
setup.py
View file @
2ec4b08e
...
...
@@ -68,7 +68,7 @@ setup(
install_requires
=
requirements
,
python_requires
=
'>=3.6'
,
packages
=
find_packages
(),
author
=
'
Anton Obukhov
'
,
author
=
'
Dan Povey
'
,
license
=
'BSD'
,
url
=
'https://www.github.com/toshas/torch-discounted-cumsum'
,
ext_modules
=
configure_extensions
(),
...
...
torch_learned_nonlin/learned_nonlin_test.py
View file @
2ec4b08e
...
...
@@ -11,6 +11,7 @@ def test_learned_nonlin_basic():
x
=
-
2.0
+
0.4
*
torch
.
arange
(
10
,
dtype
=
dtype
)
x
=
x
.
reshape
(
1
,
1
,
10
).
repeat
(
B
,
C
,
1
)
K
=
4
N
=
K
*
2
params
=
torch
.
arange
(
N
+
1
,
dtype
=
dtype
).
unsqueeze
(
0
)
+
torch
.
arange
(
C
,
dtype
=
dtype
).
unsqueeze
(
1
)
-
3
...
...
@@ -19,8 +20,20 @@ def test_learned_nonlin_basic():
print
(
"x = "
,
x
)
print
(
"params = "
,
params
)
print
(
"x.shape = "
,
x
.
shape
)
y
=
learned_nonlin
(
x
,
params
,
dim
=
1
)
if
True
:
# Check
x2
=
x
.
reshape
(
B
,
C
,
5
,
2
)
assert
torch
.
allclose
(
learned_nonlin
(
x
,
params
,
dim
=
1
),
learned_nonlin
(
x2
,
params
,
dim
=
1
).
reshape
(
x
.
shape
))
x2
=
x
.
reshape
(
B
,
1
,
C
,
10
)
assert
torch
.
allclose
(
learned_nonlin
(
x
,
params
,
dim
=
1
),
learned_nonlin
(
x2
,
params
,
dim
=
2
).
reshape
(
x
.
shape
))
print
(
"y = "
,
y
)
y
.
sum
().
backward
()
...
...
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