| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -140,6 +140,8 @@ RUN apt-get -y install zlib1g-dev liblcms2-dev libwebp-dev libgeos-dev && \ | |||
| 140 | 140 | # MXNet | |
| 141 | 141 | pip install mxnet && \ | |
| 142 | 142 | pip install --upgrade numpy && \ | |
| 143 | + pip install gluonnlp && \ | ||
| 144 | + pip install gluoncv && \ | ||
| 143 | 145 | # h2o (requires java) | |
| 144 | 146 | # requires java | |
| 145 | 147 | apt-get install -y default-jdk && \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,9 @@ RUN pip uninstall -y tensorflow && \ | |||
| 52 | 52 | conda install -y pytorch torchvision cudatoolkit=9.2 -c pytorch && \ | |
| 53 | 53 | /tmp/clean-layer.sh | |
| 54 | 54 | ||
| 55 | + RUN pip uninstall -y mxnet && \ | ||
| 56 | + pip install mxnet-cu92 | ||
| 57 | + | ||
| 55 | 58 | # Install GPU-only packages | |
| 56 | 59 | RUN pip install pycuda && \ | |
| 57 | 60 | pip install cupy-cuda92 && \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,37 @@ | |||
| 1 | + import unittest | ||
| 2 | + from common import gpu_test | ||
| 3 | + | ||
| 4 | + import mxnet as mx | ||
| 5 | + from gluonnlp import Vocab | ||
| 6 | + from gluonnlp.data import count_tokens | ||
| 7 | + | ||
| 8 | + from gluoncv.data.transforms.image import imresize | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + class TestMxNet(unittest.TestCase): | ||
| 12 | + def test_array(self): | ||
| 13 | + x = mx.nd.array([[1, 2, 3], [4, 5, 6]]) | ||
| 14 | + | ||
| 15 | + self.assertEqual((2, 3), x.shape) | ||
| 16 | + | ||
| 17 | + @gpu_test | ||
| 18 | + def test_array_gpu(self): | ||
| 19 | + x = mx.nd.array([2, 2, 2], ctx=mx.gpu(0)) | ||
| 20 | + y = mx.nd.array([1, 1, 1], ctx=mx.gpu(0)) | ||
| 21 | + self.assertEqual(3, ((x - y).sum().asscalar())) | ||
| 22 | + | ||
| 23 | + def test_gluon_nlp(self): | ||
| 24 | + # get corpus statistics | ||
| 25 | + counter = count_tokens(['alpha', 'beta', 'gamma', 'beta']) | ||
| 26 | + # create Vocab | ||
| 27 | + vocab = Vocab(counter) | ||
| 28 | + # find index based on token | ||
| 29 | + self.assertEqual(4, vocab['beta']) | ||
| 30 | + | ||
| 31 | + def test_gluon_cv(self): | ||
| 32 | + # create fake RGB image of 300x300 of shape: Height x Width x Channel as OpenCV expects | ||
| 33 | + img = mx.random.uniform(0, 255, (300, 300, 3)).astype('uint8') | ||
| 34 | + # resize image to 200x200. This call uses OpenCV | ||
| 35 | + # GluonCV is not of much use if OpenCV is not there or fails | ||
| 36 | + img = imresize(img, 200, 200) | ||
| 37 | + self.assertEqual((200, 200, 3), img.shape) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments