How to use the @tensorflow/tfjs-layers.model 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-layers / integration_tests / tfjs2keras / tfjs_save.js View on Github external
async function exportFunctionalMergeModel(exportPath) {
  const input1 = tfl.input({shape: [2, 5]});
  const input2 = tfl.input({shape: [4, 5]});
  const input3 = tfl.input({shape: [30]});
  const reshaped1 = tfl.layers.reshape({targetShape: [10]}).apply(input1);
  const reshaped2 = tfl.layers.reshape({targetShape: [20]}).apply(input2);
  const dense1 = tfl.layers.dense({units: 5}).apply(reshaped1);
  const dense2 = tfl.layers.dense({units: 5}).apply(reshaped2);
  const dense3 = tfl.layers.dense({units: 5}).apply(input3);
  const avg = tfl.layers.average().apply([dense1, dense2]);
  const concat = tfl.layers.concatenate({axis: -1}).apply([avg, dense3]);
  const output = tfl.layers.dense({units: 1}).apply(concat);
  const model = tfl.model({inputs: [input1, input2, input3], outputs: output});

  await saveModelAndRandomInputsAndOutputs(model, exportPath);
}
github tensorflow / tfjs / tfjs-layers / integration_tests / tfjs2keras / tfjs_save.js View on Github external
async function exportFunctionalMergeModel(exportPath) {
  const input1 = tfl.input({shape: [2, 5]});
  const input2 = tfl.input({shape: [4, 5]});
  const input3 = tfl.input({shape: [30]});
  const reshaped1 = tfl.layers.reshape({targetShape: [10]}).apply(input1);
  const reshaped2 = tfl.layers.reshape({targetShape: [20]}).apply(input2);
  const dense1 = tfl.layers.dense({units: 5}).apply(reshaped1);
  const dense2 = tfl.layers.dense({units: 5}).apply(reshaped2);
  const dense3 = tfl.layers.dense({units: 5}).apply(input3);
  const avg = tfl.layers.average().apply([dense1, dense2]);
  const concat = tfl.layers.concatenate({axis: -1}).apply([avg, dense3]);
  const output = tfl.layers.dense({units: 1}).apply(concat);
  const model = tfl.model({inputs: [input1, input2, input3], outputs: output});

  await saveModelAndRandomInputsAndOutputs(model, exportPath);
}