Function setBackend

  • Sets the backend (cpu, webgl, wasm, etc) responsible for creating tensors and executing operations on those tensors. Returns a promise that resolves to a boolean if the backend initialization was successful.

    Note this disposes the current backend, if any, as well as any tensors associated with it. A new backend is initialized, even if it is of the same type as the previous one.

    Parameters

    • backendName: string

      The name of the backend. Currently supports 'webgl'|'cpu' in the browser, 'tensorflow' under node.js (requires tfjs-node), and 'wasm' (requires tfjs-backend-wasm).

    Returns Promise<boolean>

    Doc