FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docker-python/tests/test_mxnet.py at master · AI-For-Rural/docker-python · GitHub
AI-For-Rural
/
docker-python
Public
forked from
Kaggle/docker-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
docker-python
/
tests
/
test_mxnet.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (29 loc) · 1.19 KB
Breadcrumbs
docker-python
/
tests
/
test_mxnet.py
Copy path
File metadata and controls
37 lines (29 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import
unittest
from
common
import
gpu_test
import
mxnet
as
mx
from
gluonnlp
import
Vocab
from
gluonnlp
.
data
import
count_tokens
from
gluoncv
.
data
.
transforms
.
image
import
imresize
class
TestMxNet
(
unittest
.
TestCase
):
def
test_array
(
self
):
x
=
mx
.
nd
.
array
([[
1
,
2
,
3
], [
4
,
5
,
6
]])
self
.
assertEqual
((
2
,
3
),
x
.
shape
)
@
gpu_test
def
test_array_gpu
(
self
):
x
=
mx
.
nd
.
array
([
2
,
2
,
2
],
ctx
=
mx
.
gpu
(
0
))
y
=
mx
.
nd
.
array
([
1
,
1
,
1
],
ctx
=
mx
.
gpu
(
0
))
self
.
assertEqual
(
3
, ((
x
-
y
).
sum
().
asscalar
()))
def
test_gluon_nlp
(
self
):
# get corpus statistics
counter
=
count_tokens
([
'alpha'
,
'beta'
,
'gamma'
,
'beta'
])
# create Vocab
vocab
=
Vocab
(
counter
)
# find index based on token
self
.
assertEqual
(
4
,
vocab
[
'beta'
])
def
test_gluon_cv
(
self
):
# create fake RGB image of 300x300 of shape: Height x Width x Channel as OpenCV expects
img
=
mx
.
random
.
uniform
(
0
,
255
, (
300
,
300
,
3
)).
astype
(
'uint8'
)
# resize image to 200x200. This call uses OpenCV
# GluonCV is not of much use if OpenCV is not there or fails
img
=
imresize
(
img
,
200
,
200
)
self
.
assertEqual
((
200
,
200
,
3
),
img
.
shape
)
Back
|
FazBrowse Home
|
New Git URL