thao p nguyen created SINGA-444: ----------------------------------- Summary: Can not run Models' examples on Singa documentation Key: SINGA-444 URL: https://issues.apache.org/jira/browse/SINGA-444 Project: Singa Issue Type: Bug Components: Documentation Environment: - python 3.6.8 - Ubuntu 18.10 Reporter: thao p nguyen
Following the Singa documentation, the API code for running models' example does not work. Below are messages: 1) FeedForward Net >>> from singa import tensor >>> from singa import loss >>> x = tensor.Tensor((3, 5)) >>> x.uniform(0, 1) # randomly genearte the prediction activation >>> y = tensor.from_numpy(np.array([0, 1, 3], dtype=np.int)) # set the truth Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'np' is not defined >>> f = loss.SoftmaxCrossEntropy() >>> l = f.forward(True, x, y) # l is tensor with 3 loss values Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'y' is not defined >>> g = f.backward() # g is a tensor containing all gradients of x w.r.t l Segmentation fault (core dumped) 2) Loss >>> from singa import tensor >>> from singa import loss >>> >>> x = tensor.Tensor((3, 5)) >>> x.uniform(0, 1) # randomly genearte the prediction activation >>> y = tensor.from_numpy(np.array([0, 1, 3], dtype=np.int)) # set the truth Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'np' is not defined >>> >>> f = loss.SoftmaxCrossEntropy() >>> l = f.forward(True, x, y) # l is tensor with 3 loss values Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'y' is not defined >>> g = f.backward() # g is a tensor containing all gradients of x w.r.t l 3) >>> from singa import tensor >>> from singa import metric >>> >>> x = tensor.Tensor((3, 5)) >>> x.uniform(0, 1) # randomly genearte the prediction activation >>> x = tensor.SoftMax(x) # normalize the prediction into probabilities Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'singa.tensor' has no attribute 'SoftMax' >>> y = tensor.from_numpy(np.array([0, 1, 3], dtype=np.int)) # set the truth Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'np' is not defined >>> >>> f = metric.Accuracy() >>> acc = f.evaluate(x, y) # averaged accuracy over all 3 samples in x -- This message was sent by Atlassian JIRA (v7.6.3#76005)