tfjs/tfjs-core
Valérian Rousset dc7261728f
[tfjs-core] do not hang on invalid browser files (#8517)
`tf.io.browserFiles` doesn't fail when loading invalid files. or rather, it fails, but never rejects the promise, making the `IOHandler.load` hang forever.

wrapping the `JSON.parse` call in a try/catch and rejecting accordingly did the trick. and a small test to try it out.

note: `FileReader.readAsText()` is a callback way to go around reading files. the promise-based `Blob.text()` would make `BrowserFile.load` simpler and safer (but felt ouf-of-scope here).
2025-04-23 18:59:09 +00:00
..
.vscode
development
scripts Fix typos in the documentation strings of the tfjs-core directory (#8413) 2024-10-10 23:24:41 +00:00
src [tfjs-core] do not hang on invalid browser files (#8517) 2025-04-23 18:59:09 +00:00
.bazelrc
.npmignore
.npmrc
BUILD.bazel
README.md
package.json webgpu: apply the new timestampWrites format (#8048) 2023-11-03 15:07:37 +08:00
test.html
tsconfig.json
yarn.lock webgpu: apply the new timestampWrites format (#8048) 2023-11-03 15:07:37 +08:00

README.md

TensorFlow.js Core API

A part of the TensorFlow.js ecosystem, this repo hosts @tensorflow/tfjs-core, the TensorFlow.js Core API, which provides low-level, hardware-accelerated linear algebra operations and an eager API for automatic differentiation.

Check out js.tensorflow.org for more information about the library, tutorials and API docs.

To keep track of issues we use the tensorflow/tfjs Github repo.

Importing

You can install TensorFlow.js via yarn or npm. We recommend using the @tensorflow/tfjs npm package, which gives you both this Core API and the higher-level Layers API:

import * as tf from '@tensorflow/tfjs';
// You have the Core API: tf.matMul(), tf.softmax(), ...
// You also have Layers API: tf.model(), tf.layers.dense(), ...

On the other hand, if you care about the bundle size and you do not use the Layers API, you can import only the Core API:

import * as tfc from '@tensorflow/tfjs-core';
// You have the Core API: tfc.matMul(), tfc.softmax(), ...
// No Layers API.

Note: If you are only importing the Core API, you also need to import a backend (e.g., tfjs-backend-cpu, tfjs-backend-webgl, tfjs-backend-wasm).

For info about development, check out DEVELOPMENT.md.

For more information

Thanks BrowserStack for providing testing support.