Uploaded image for project: 'Singa'
  1. Singa
  2. SINGA-444

Can not run Model classes examples on Singa documentation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • Documentation
    • None
    • - python 3.6.8
      - Ubuntu 18.10

    Description

      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 # 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

      Attachments

        Activity

          People

            Unassigned Unassigned
            pinpom thao p nguyen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: