Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7376 Allow seeding the Orthogonal Initializer and use QR instead of gramSchmidt #7377

Conversation

cosminc98
Copy link
Contributor

@cosminc98 cosminc98 commented Feb 14, 2023

Allow seeding the Orthogonal Initializer and add test. Use QR instead of gramSchmidt for consistency with the python implementation.

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@google-cla
Copy link

google-cla bot commented Feb 14, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

…d use QR decomposition method instead of gramSchmidt for consistency with the python implementation
@cosminc98 cosminc98 force-pushed the feature-7376-orthogonal-initializer-seed-qr branch from 0b9f409 to ae174dc Compare February 14, 2023 14:31
Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 approvals obtained (waiting on @cosminc98)


tfjs-layers/src/initializers.ts line 557 at r1 (raw file):

      for (const dim of shape.slice(0, -1)) {
        numRows *= dim;
      }

You can use the util.sizeFromShape(shape) method from tfjs-core

Code quote:

      let numRows = 1;
      for (const dim of shape.slice(0, -1)) {
        numRows *= dim;
      }

tfjs-layers/src/initializers.ts line 568 at r1 (raw file):

      const maxDim = Math.max(numCols, numRows);
      const minDim = Math.min(numCols, numRows);
      const flatShape = [maxDim, minDim];

Prefer removing the intermediate variables:
const flatShape = [Math.max(numCols, numRows), Math.min(numCols, numRows)];

Code quote:

      const maxDim = Math.max(numCols, numRows);
      const minDim = Math.min(numCols, numRows);
      const flatShape = [maxDim, minDim];
… variables in Orthogonal Initializer apply method
@cosminc98 cosminc98 force-pushed the feature-7376-orthogonal-initializer-seed-qr branch from 3cb4348 to 90e8a36 Compare February 15, 2023 07:09
Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained

Copy link
Member

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants