Skip to content

The nondeterministic computation order of Jacobian #46

Description

@xchen-cs

The computation order of Jacobian in Chumpy is nondeterministic. This in cases leads to different optimization results from run to run, since the numerical approximation errors are dependent on the computation order. Specifically, the function dr_wrt() in class Ch has the following code:

for k in set(self.dterms).intersection(propnames.union(set(self.__dict__.keys()))):
    ...

The set is an unordered container in python, and what's even worse for science computation is that its access order is nondeterministic. A quick fix to this could be adding a call to sorted():

for k in sorted(set(self.dterms).intersection(propnames.union(set(self.__dict__.keys())))):
    ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions