[GitHub] [incubator-singa] joddiy commented on a change in pull request #504: SINGA-481 Reconsturct soonx

2019-08-12 Thread GitBox
joddiy commented on a change in pull request #504: SINGA-481 Reconsturct soonx
URL: https://github.com/apache/incubator-singa/pull/504#discussion_r313209763
 
 

 ##
 File path: test/python/test_onnx.py
 ##
 @@ -0,0 +1,202 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# =
+
+import unittest
+from builtins import str
+
+from singa import tensor
+from singa import singa_wrap as singa
+from singa import autograd
+from singa import sonnx
+
+import onnx
+from onnx import (defs, checker, helper, numpy_helper, mapping,
+  ModelProto, GraphProto, NodeProto, AttributeProto, 
TensorProto, OperatorSetIdProto)
+from onnx.helper import make_tensor, make_tensor_value_info, make_node, 
make_graph
+
+from cuda_helper import gpu_dev, cpu_dev
+
+import numpy as np
+
+autograd.training = True
+
+
+class TestPythonOnnxFrontend(unittest.TestCase):
+
 
 Review comment:
   These tese cases are only backend part, that is, they make two tensors, one 
as input, one as output, then they convert the op to other frameworks, run it 
and then transfer back the output, they check whether the framework's output is 
same with the pre-defined onnx's output.
   They haven't tested the frontend part.
   Our test cases are converting the singa op to onnx, and convert back, to 
check the output of singa ops after and before converted whether are same.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] joddiy commented on a change in pull request #504: SINGA-481 Reconsturct soonx

2019-08-12 Thread GitBox
joddiy commented on a change in pull request #504: SINGA-481 Reconsturct soonx
URL: https://github.com/apache/incubator-singa/pull/504#discussion_r313209881
 
 

 ##
 File path: test/python/test_onnx.py
 ##
 @@ -0,0 +1,202 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# =
+
+import unittest
+from builtins import str
+
+from singa import tensor
+from singa import singa_wrap as singa
+from singa import autograd
+from singa import sonnx
+
+import onnx
+from onnx import (defs, checker, helper, numpy_helper, mapping,
+  ModelProto, GraphProto, NodeProto, AttributeProto, 
TensorProto, OperatorSetIdProto)
+from onnx.helper import make_tensor, make_tensor_value_info, make_node, 
make_graph
+
+from cuda_helper import gpu_dev, cpu_dev
+
+import numpy as np
+
+autograd.training = True
+
+
+class TestPythonOnnxFrontend(unittest.TestCase):
+
 
 Review comment:
   And, please don't merge this PR now.
   I found I omited a commit, and I also want to finish the transfer learning 
firstly. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] joddiy commented on a change in pull request #504: SINGA-481 Reconsturct soonx

2019-08-12 Thread GitBox
joddiy commented on a change in pull request #504: SINGA-481 Reconsturct soonx
URL: https://github.com/apache/incubator-singa/pull/504#discussion_r313209763
 
 

 ##
 File path: test/python/test_onnx.py
 ##
 @@ -0,0 +1,202 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# =
+
+import unittest
+from builtins import str
+
+from singa import tensor
+from singa import singa_wrap as singa
+from singa import autograd
+from singa import sonnx
+
+import onnx
+from onnx import (defs, checker, helper, numpy_helper, mapping,
+  ModelProto, GraphProto, NodeProto, AttributeProto, 
TensorProto, OperatorSetIdProto)
+from onnx.helper import make_tensor, make_tensor_value_info, make_node, 
make_graph
+
+from cuda_helper import gpu_dev, cpu_dev
+
+import numpy as np
+
+autograd.training = True
+
+
+class TestPythonOnnxFrontend(unittest.TestCase):
+
 
 Review comment:
   These tese cases are only backend part, that is, the onnx's test case is 
they make two tensors, one as input, one as output, then they convert the op to 
other framework, run it and then transfer back the output, they check whether 
the framework's output is same with the pre-defined onnx's output.
   They haven't tested the frontend part.
   Our test cases are converting the singa op to onnx, and convert back, to 
check the singa ops after and before converted whether are same.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] ShichengChen edited a comment on issue #502: SINGA-474 Clip operator

2019-08-12 Thread GitBox
ShichengChen edited a comment on issue #502: SINGA-474 Clip operator
URL: https://github.com/apache/incubator-singa/pull/502#issuecomment-520658575
 
 
   > the same code appears in both #503 and #502 .
   > you can add feature A, commit and send PR A; then add feature B, commit 
and send PR B;
   > you can also skip PR A and just send PR B.
   > but when you have feature A, B, ...; then you'd better split this big PR 
into multiple small PRs.
   
   I just removed useless code and split them into two PR


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] ShichengChen commented on issue #502: SINGA-474 Clip operator

2019-08-12 Thread GitBox
ShichengChen commented on issue #502: SINGA-474 Clip operator
URL: https://github.com/apache/incubator-singa/pull/502#issuecomment-520658575
 
 
   > the same code appears in both #503 and #502 .
   > you can add feature A, commit and send PR A; then add feature B, commit 
and send PR B;
   > you can also skip PR A and just send PR B.
   > but when you have feature A, B, ...; then you'd better split this big PR 
into multiple small PRs.
   
   I just remove useless code and split them into two PR


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] nudles commented on issue #502: SINGA-474 Clip operator

2019-08-12 Thread GitBox
nudles commented on issue #502: SINGA-474 Clip operator
URL: https://github.com/apache/incubator-singa/pull/502#issuecomment-520653605
 
 
   the same code appears in both #503 and #502 .
   you can add feature A, commit and send PR A; then add feature B, commit and 
send PR B; 
   you can also skip PR A and just send PR B.
   but when you have feature A, B, ...; then you'd better split this big PR 
into multiple small PRs.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] nudles commented on a change in pull request #504: SINGA-481 Reconsturct soonx

2019-08-12 Thread GitBox
nudles commented on a change in pull request #504: SINGA-481 Reconsturct soonx
URL: https://github.com/apache/incubator-singa/pull/504#discussion_r313189915
 
 

 ##
 File path: test/python/test_onnx.py
 ##
 @@ -0,0 +1,202 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# =
+
+import unittest
+from builtins import str
+
+from singa import tensor
+from singa import singa_wrap as singa
+from singa import autograd
+from singa import sonnx
+
+import onnx
+from onnx import (defs, checker, helper, numpy_helper, mapping,
+  ModelProto, GraphProto, NodeProto, AttributeProto, 
TensorProto, OperatorSetIdProto)
+from onnx.helper import make_tensor, make_tensor_value_info, make_node, 
make_graph
+
+from cuda_helper import gpu_dev, cpu_dev
+
+import numpy as np
+
+autograd.training = True
+
+
+class TestPythonOnnxFrontend(unittest.TestCase):
+
 
 Review comment:
   Can we use onnx's test code?
   https://github.com/onnx/onnx/tree/master/onnx/backend/test/case


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] joddiy opened a new pull request #504: Reconsturct soonx

2019-08-12 Thread GitBox
joddiy opened a new pull request #504: Reconsturct soonx
URL: https://github.com/apache/incubator-singa/pull/504
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Created] (SINGA-481) Reconstruct SONNX

2019-08-12 Thread zhangzhaoqi (JIRA)
zhangzhaoqi created SINGA-481:
-

 Summary: Reconstruct SONNX
 Key: SINGA-481
 URL: https://issues.apache.org/jira/browse/SINGA-481
 Project: Singa
  Issue Type: New Feature
Reporter: zhangzhaoqi


* Reconstruct the frontend and backend of soonx, and make it support transfer 
learning. 
 * Develop soonx operators: conv2d, relu, avg_pool, softmax, sigmoid, add, 
concat, matmul

 
 * Add these operators' test cases.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[GitHub] [incubator-singa] ShichengChen opened a new pull request #503: SINGA-474 prelu operator

2019-08-12 Thread GitBox
ShichengChen opened a new pull request #503: SINGA-474 prelu operator
URL: https://github.com/apache/incubator-singa/pull/503
 
 
   SINGA-474 prelu operator for autograd and ONNX operator


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] ShichengChen opened a new pull request #502: SINGA-474 Clip operator

2019-08-12 Thread GitBox
ShichengChen opened a new pull request #502: SINGA-474 Clip operator
URL: https://github.com/apache/incubator-singa/pull/502
 
 
   SINGA-474 Clip operator for autograd and ONNX


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] ShichengChen commented on a change in pull request #482: SINGA-474 hardsigmoid operator

2019-08-12 Thread GitBox
ShichengChen commented on a change in pull request #482: SINGA-474 hardsigmoid 
operator
URL: https://github.com/apache/incubator-singa/pull/482#discussion_r312793257
 
 

 ##
 File path: python/singa/autograd.py
 ##
 @@ -358,6 +358,51 @@ def relu(x):
 return ReLU()(x)[0]
 
 
+class HardSigmoid(Operation):
+def __init__(self,alpha=0.2,gamma=0.5):
+super(HardSigmoid, self).__init__()
+self.alpha=alpha
+self.gamma=gamma
+
+def forward(self, x):
+"""Do forward propgation.
+#y = max(0, min(1, alpha * x + gamma))
+Args:
+x (CTensor): matrix
+Returns:
+a CTensor for the result
+"""
+if training:
+self.input = x
+
+x = singa.AddFloat(singa.MultFloat(x,self.alpha),self.gamma)
+x = singa.ReLU(x)
+mask = singa.LTFloat(x, 1.0)
+mask2 = singa.GEFloat(x, 1.0)
+
+ans = singa.__add__(singa.__mul__(x, mask),mask2)
+return singa.ReLU(ans)
+
+def backward(self, dy):
+"""
+Args:
+dy (CTensor): data for the dL / dy, L is the loss
+Returns:
+a (CTensor) dx
+"""
+
+x = singa.AddFloat(singa.MultFloat(self.input,self.alpha),self.gamma)
 
 Review comment:
   yes, I just cached. We do not have clip operation now


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-singa] ShichengChen commented on a change in pull request #480: SINGA-474 ELU operator

2019-08-12 Thread GitBox
ShichengChen commented on a change in pull request #480: SINGA-474 ELU operator
URL: https://github.com/apache/incubator-singa/pull/480#discussion_r312789335
 
 

 ##
 File path: python/singa/autograd.py
 ##
 @@ -358,6 +358,48 @@ def relu(x):
 return ReLU()(x)[0]
 
 
+class Elu(Operation):
+def __init__(self,alpha=1):
+super(Elu, self).__init__()
+self.alpha=alpha
+
+def forward(self, x):
+"""Do forward propgation.
+Store the x if requires gradient.
+Args:
+x (CTensor): matrix
+Returns:
+a CTensor for the result
+"""
+#f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0
+if training:
+self.input = x
+x1 = singa.LTFloat(x, 0.0)
+x1 = singa.__mul__(x, x1)
+x1 = singa.SubFloat(singa.Exp(x1),self.alpha)
 
 Review comment:
   sorry for my fault, I just modified


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services