How to use the @tensorflow/tfjs-layers.LayersModel function in @tensorflow/tfjs-layers

To help you get started, we’ve selected a few @tensorflow/tfjs-layers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensorflow / tfjs / tfjs / integration_tests / models / common.ts View on Github external
return tfc.tidy(() => {
    let xs: tfc.Tensor|tfc.Tensor[] = [];
    for (const input of model.inputs) {
      xs.push(tfc.randomUniform([batchSize].concat(input.shape.slice(1))));
    }
    if (xs.length === 1) {
      xs = xs[0];
    }

    let ys: tfc.Tensor|tfc.Tensor[] = [];
    if (model instanceof tfl.LayersModel) {
      for (const output of model.outputs) {
        ys.push(tfc.randomUniform([batchSize].concat(output.shape.slice(1))));
      }
      if (ys.length === 1) {
        ys = ys[0];
      }
    }

    return {xs, ys};
  });
}