diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..63db215 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,22 @@ +name: linux-x64-gcc +on: [push, pull_request] +jobs: + linux-x64-gcc: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: install dependencies + run: | + pip install --upgrade pip + pip install -v -e . + pip install coveralls nose + - name: cpu-test + run: nosetests -s --with-coverage diff --git a/.gitmodules b/.gitmodules index 35aef46..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "thirdparty/numpy-groupies"] - path = thirdparty/numpy-groupies - url = https://github.com/ml31415/numpy-groupies diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b0d251c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -sudo: false - -cache: - directories: - - $HOME/env - -language: python - -notifications: - email: false - -python: - - 2.7 - - 3.6 - -script: - - pip install python-coveralls - - nosetests --with-coverage - -after_success: - - coveralls diff --git a/examples/mnist_kaggle.py b/examples/mnist_kaggle.py index 843ecef..f3260cb 100644 --- a/examples/mnist_kaggle.py +++ b/examples/mnist_kaggle.py @@ -68,7 +68,7 @@ def print_info(): n = len(data) X = data[:, 1:] -labels = data[:, 0].astype(np.int) +labels = data[:, 0].astype(np.int32) # one-hot #Y = np.eye(10)[labels.ravel()] print ("Read OK", n) diff --git a/examples/mnist_train.py b/examples/mnist_train.py index aaeb9d2..31e517c 100644 --- a/examples/mnist_train.py +++ b/examples/mnist_train.py @@ -25,7 +25,7 @@ n = len(data) X = data[:, 1:] -labels = data[:, 0].astype(np.int) +labels = data[:, 0].astype(np.int32) # one-hot #Y = np.eye(10)[labels.ravel()] print ("Read OK", n) diff --git a/mobula/layers/Eltwise.py b/mobula/layers/Eltwise.py index 00bc5d0..0ba39b8 100644 --- a/mobula/layers/Eltwise.py +++ b/mobula/layers/Eltwise.py @@ -25,7 +25,7 @@ def forward(self): elif self.op == Eltwise.PROD: for i in range(len(self.X)): x = self.X[i] - x[x == 0] = 1e-100 + x[x == 0] = 1e-10 self.Y = np.prod(self.X, 0) * np.prod(self.coeffs) else: # self.op == Eltwise.MAX diff --git a/tests/test_layers/test_batchnorm.py b/tests/test_layers/test_batchnorm.py index 80db47b..9ffb2eb 100644 --- a/tests/test_layers/test_batchnorm.py +++ b/tests/test_layers/test_batchnorm.py @@ -42,7 +42,7 @@ def test_grads(): momentum = 0.9 eps = 1e-5 use_global_stats = False - X = np.arange(24).reshape((4, 6)).astype(np.float) + X = np.arange(24).reshape((4, 6)).astype(np.float32) bn = L.BatchNorm(None, momentum = momentum, eps = eps, use_global_stats = use_global_stats) bn.X = X bn.reshape() diff --git a/tests/test_layers/test_contrastive.py b/tests/test_layers/test_contrastive.py index a586c29..350766b 100644 --- a/tests/test_layers/test_contrastive.py +++ b/tests/test_layers/test_contrastive.py @@ -2,8 +2,8 @@ import numpy as np def test_contrastive(): - A = np.array([[1,2,0], [2,1,0]]).astype(np.float) - B = np.array([[0,1,3], [2,3,1]]).astype(np.float) + A = np.array([[1,2,0], [2,1,0]]).astype(np.float32) + B = np.array([[0,1,3], [2,3,1]]).astype(np.float32) diff = A - B # 2 x 3 dist_sq = np.sum(np.square(diff), 1).reshape((2,1)) # 2 x 1 diff --git a/tests/test_layers/test_eltwise.py b/tests/test_layers/test_eltwise.py index e2f251f..703a538 100644 --- a/tests/test_layers/test_eltwise.py +++ b/tests/test_layers/test_eltwise.py @@ -3,18 +3,19 @@ import numpy as np def go_eltwise(op): - a = np.array([1,0,6]).astype(np.float) - b = np.array([4,5,3]).astype(np.float) + a = np.array([1,0,6]).astype(np.float32) + b = np.array([4,5,3]).astype(np.float32) print ("a: ", a) print ("b: ", b) data1 = L.Data(a) data2 = L.Data(b) coeffs = np.array([-1.0,1.2]) l = L.Eltwise([data1,data2], op = op, coeffs = coeffs) + print ('coeffs: ', coeffs) l.reshape() l.forward() print ("Y: ", l.Y) - dY = np.array([7, 8, 9]).astype(np.float) + dY = np.array([7, 8, 9]).astype(np.float32) l.dY = dY print ("dY: ", l.dY) l.backward() @@ -38,7 +39,7 @@ def go_eltwise(op): print ("Y", l.Y, Y) assert np.allclose(l.Y, Y) - assert np.allclose(l.dX[0], dX0) + assert np.allclose(l.dX[0], dX0), (l.dX[0], dX0) assert np.allclose(l.dX[1], dX1) def test_eltwise(): diff --git a/tests/test_layers/test_name.py b/tests/test_layers/test_name.py index 182a102..2eea433 100644 --- a/tests/test_layers/test_name.py +++ b/tests/test_layers/test_name.py @@ -8,22 +8,22 @@ def test_name(): test1 = [str(L.Data(a)), str(L.Data([a,b])), str(L.Data(None))] test1_truth = ["", "", ""] print (test1) - assert test1 == test1_truth + assert test1 == test1_truth, (test1, test1_truth) test2 = [str(L.ReLU(L.Data(a))), str(L.ReLU(L.FC(L.Data(b), dim_out = 10)))] test2_truth = ["", ""] print (test2) - assert test2 == test2_truth + assert test2 == test2_truth, (test2, test2_truth) la, lc = L.Data([a,c]) concat = L.Concat([la, lc], axis = 0) test3 = [str(concat)] test3_truth = [""] print (test3) - assert test3 == test3_truth + assert test3 == test3_truth, (test3, test3_truth) l = L.ReLU(a) test4 = [str(l)] test4_truth = [""] print (test4) - assert test4 == test4_truth + assert test4 == test4_truth, (test4, test4_truth) diff --git a/thirdparty/numpy-groupies b/thirdparty/numpy-groupies deleted file mode 160000 index dffc66e..0000000 --- a/thirdparty/numpy-groupies +++ /dev/null @@ -1 +0,0 @@ -Subproject commit dffc66eca9421505688d903b1fe1a8746d38bd1f