-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Layers] Update weights loading for keras v3. #7761
Conversation
This reverts commit 3bd7e8f.
Draft a script for build map of TFJS class and TF module path.
DOC * Improve example * add
…rflow#7550) Some TFJS packages, like wasm, have examples or demos in them. These usually depend on the parent package, but the parent package is not marked as to be updated when updating the subpackage dependency versions. For an example of this, see tensorflow#7547. Update the TFJS dependencies of these subpackages to the release version if they are `link:` dependencies.
* Fix sin/cos workaround * Add tests for large numbers * Fix tan * Exclude new tests in webgl and webgpu * Fix * Exclude tests in tfjs-node * Update * Fix * Fix * Fix * Remove comments
* wip * Add xnn_caches * Upgrade xnnpack * exp * Update xnnpack deps * Fix xnn cache * TEST * Cleanup * Cleanup * Cleanup * Update xnnpack * Add flag to avoid unused function * Add comment * Add config to turn xnnpack logs off * Add sha256 for emsdk * Update xnnpack and toolchain, and disable xnn caches * Fix lint * Remove unused include
…7695) Killing the verdaccio process throws an error because the disconnect event emits when the process is killed. We throw an error on a disconnect to catch any unexpected verdaccio disconnections. Fix this by deregistering the disconnect handler before killing the verdaccio process.
* webgpu: Optimize SpaceToBatchND Fuse pad and transpose to one shader. See 20% improvement for SpaceToBatchND in DeepLabV3
…rflow#7714) * webgpu: Replace timestamp-query-in-passes with timestamp-query Timestamp-query has a broader support than timestamp-query-in-passes on all platforms, including macOS. Note that Chrome switch '--disable-dawn-features=disallow_unsafe_apis' is still needed now as the timestamp has the accuracy of nanosecond, which is too accurate to be safe. Later changes in Chrome may lift this limitation.
If a pass that needs timestamp query follows a pass without timestamp query, querySet may not be created as expected. This PR fixes this issue.
The warning should only happen when there is real data reading from gpu to cpu.
* Fix indexeddb for 1GB models Fixes tensorflow#7702 by concatenating model weights into a single ArrayBuffer before sending them to IndexedDB. A better solution would be to store the model as multiple records, but this quick fix is easy to implement solves the issue for most current models (~1GB). * Use CompositeArrayBuffer.join
…rflow#7674) * npmVersion CLIarg * add readme description --------- Co-authored-by: Linchenn <40653845+Linchenn@users.noreply.github.com> Co-authored-by: Matthew Soulanille <msoulanille@google.com>
Update the workflow file to replace 'stale-master' probot with a github action. It will add 'stale' label to inactive issues/PRs if contains 'stat:awaiting response' label in case of further inactivity it will close the issue with proper comment.
* Fix getLayer() API * Apply suggested changes
Draft a script for build map of TFJS class and TF module path.
…ensorflow#7731) Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.2.2 to 4.2.4. - [Release notes](https://github.com/socketio/socket.io-parser/releases) - [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md) - [Commits](socketio/socket.io-parser@4.2.2...4.2.4) --- updated-dependencies: - dependency-name: socket.io-parser dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthew Soulanille <msoulanille@google.com>
tensorflow#7730) Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.2.1 to 4.2.4. - [Release notes](https://github.com/socketio/socket.io-parser/releases) - [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md) - [Commits](socketio/socket.io-parser@4.2.1...4.2.4) --- updated-dependencies: - dependency-name: socket.io-parser dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…orflow#7729) Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.2.1 to 4.2.4. - [Release notes](https://github.com/socketio/socket.io-parser/releases) - [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md) - [Commits](socketio/socket.io-parser@4.2.1...4.2.4) --- updated-dependencies: - dependency-name: socket.io-parser dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ensorflow#7666) The current code isn't great in that the vec4 shaders have diverged from the scalar ones more than necessary. Here is the common preparation work, so that following refactoring can be done on a per-op basis.
Bumps [semver](https://github.com/npm/node-semver) from 7.3.7 to 7.5.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md) - [Commits](npm/node-semver@v7.3.7...v7.5.2) --- updated-dependencies: - dependency-name: semver dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Manually write a polyfill for string.matchAll to unblock tensorflow#7770. This should be replaced with core-js in the future.
Co-authored-by: Ping Yu <4018+pyu10055@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some nits. Thanks!
tfjs-layers/src/engine/container.ts
Outdated
// get weights key from tensor map in order to check if it is from keras v3. | ||
// e.g. dense/0 | ||
const key = Object.keys(weights)[0].split('/'); | ||
const isKerasV3 = this.isKerasKeras(key[key.length - 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about change it to const isKerasFormat = this.isKerasFormat
or maybe isKerasKerasFormat
? Sorry for swinging about the name.
tfjs-layers/src/engine/container.ts
Outdated
@@ -642,6 +652,10 @@ export abstract class Container extends Layer { | |||
batchSetValue(weightValueTuples); | |||
} | |||
|
|||
private isKerasKeras(str: string): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add some comments to describe what's keras-keras format
, like: keras-keras format names weight as 'layerName/index', instead of layerName/weightName'
.
tfjs-layers/src/engine/container.ts
Outdated
* Helper function to check whether the string is from keras keras format. | ||
* keras-keras format naming the weights as 'layerName/Index' instead of | ||
* "layerName/weightName". | ||
* @returns Boolean to indicate whether in Keras keras format. | ||
*/ | ||
private isKerasKerasFormat(str: string): boolean { | ||
return !isNaN(parseInt(str, 10)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Is KerasKeras
what keras calls their saved model format that supports fully loading the model with all objects (instead of just the model graph for inference)? isKerasKerasFormat
is a confusing name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to isKerasSavedModelFormat
. This may more clear since the keras called it savedmodel format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Update the loadWeights function to support keras v3 format.
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.