Giter VIP home page Giter VIP logo

Comments (6)

chrishkchris avatar chrishkchris commented on July 4, 2024

A highlight is why the reshaped tensor have different shape?
see test_reshape_gpu

Then, other test failure should be due to very small numerical errors (order of 1e-5) that can be fixed by reducing the number of significant in comparison.

from singa.

dcslin avatar dcslin commented on July 4, 2024

should we make travis build fail when encountering errors raised from python unit test?

from singa.

chrishkchris avatar chrishkchris commented on July 4, 2024

should we make travis build fail when encountering errors raised from python unit test?

In my opinion, this is a very good feature. However, I am not sure if the machine that runs the test case by travis has GPU.
On the other hand, this test_operation.py is still important because it lets the developers to check whether the system has any problem after their commits.

from singa.

chrishkchris avatar chrishkchris commented on July 4, 2024

If I am correct, the reshape is due to the error in backward:

class Reshape(Operation):

    def __init__(self,shape):
        super(Reshape, self).__init__()
        if isinstance(shape, tensor.Tensor):
            self.shape = np.asarray(tensor.to_numpy(shape).astype(np.int32)).tolist()
        else:
            self.shape = list(shape)

    def forward(self, x):
        _shape = x.shape()
        shape = self.shape
        # handle the shape with 0
        shape = [_shape[i] if i < len(_shape) and shape[i] == 0 else shape[i] for i in range(len(shape))]
        # handle the shape with -1
        hidden_shape = int(np.prod(_shape) // np.abs(np.prod(shape)))
        self.cache=[s if s != -1 else hidden_shape for s in shape]
        return singa.Reshape(x, self.cache)

    def backward(self, dy):
        return singa.Reshape(dy, self.cache)

I think the function should change to

class Reshape(Operation):
    def __init__(self,shape):
        super(Reshape, self).__init__()
        if isinstance(shape, tensor.Tensor):
            self.shape = np.asarray(tensor.to_numpy(shape).astype(np.int32)).tolist()
        else:
            self.shape = list(shape)

    def forward(self, x):
        self._shape = x.shape()
        shape = self.shape
        # handle the shape with 0
        shape = [self._shape[i] if i < len(self._shape) and shape[i] == 0 else shape[i] for i in range(len(shape))]
        # handle the shape with -1
        hidden_shape = int(np.prod(self._shape) // np.abs(np.prod(shape)))
        self.cache=[s if s != -1 else hidden_shape for s in shape]

        return singa.Reshape(x, self.cache)

    def backward(self, dy):
        return singa.Reshape(dy, self._shape)

from singa.

chrishkchris avatar chrishkchris commented on July 4, 2024

To resolve the problem completely, I opened a hotfix at PR #579

from singa.

chrishkchris avatar chrishkchris commented on July 4, 2024

the problem is resolved completely

from singa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.