Skip to content

Commit

Permalink
Merge pull request #8 from wkcn/github_ci
Browse files Browse the repository at this point in the history
integrate GitHub Action
  • Loading branch information
wkcn authored Jun 18, 2024
2 parents 4eec938 + 6276f4d commit 2ad17c2
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 39 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "thirdparty/numpy-groupies"]
path = thirdparty/numpy-groupies
url = https://github.com/ml31415/numpy-groupies
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/mnist_kaggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/mnist_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mobula/layers/Eltwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_layers/test_batchnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_layers/test_contrastive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions tests/test_layers/test_eltwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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():
Expand Down
8 changes: 4 additions & 4 deletions tests/test_layers/test_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ def test_name():
test1 = [str(L.Data(a)), str(L.Data([a,b])), str(L.Data(None))]
test1_truth = ["<Data '/Data' input: (10,) num_output: (1)>", "<Data '/Data' input: [(10,), (3, 5)] num_output: (2)>", "<Data '/Data' input: None num_output: (0)>"]
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 = ["<ReLU '/ReLU' input: /Data:0 num_output: (1)>", "<ReLU '/ReLU' input: /FC:0 num_output: (1)>"]
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 = ["<Concat '/Concat' input: [/Data:0,/Data:1] num_output: (1)>"]
print (test3)
assert test3 == test3_truth
assert test3 == test3_truth, (test3, test3_truth)

l = L.ReLU(a)
test4 = [str(l)]
test4_truth = ["<ReLU '/ReLU' input: (10,) num_output: (1)>"]
print (test4)
assert test4 == test4_truth
assert test4 == test4_truth, (test4, test4_truth)
1 change: 0 additions & 1 deletion thirdparty/numpy-groupies
Submodule numpy-groupies deleted from dffc66

0 comments on commit 2ad17c2

Please sign in to comment.