janvier 14, 2020 —
Posted by Kangyi Zhang, Sandeep Gupta, and Brijesh Krishnaswami
TensorFlow.js is an open-source library that lets you define, train, and run machine learning models in Javascript. The library has empowered a new set of developers from the extensive JavaScript community to build and deploy machine learning models and has enabled new use cases of machine learning. For example TensorFlow.js runs in a…
const model = await tf.node.loadSavedModel(path, [tag], signatureKey);
const output = model.predict(input);
You can also feed multiple inputs to the model as an array or a map:const model1 = await tf.node.loadSavedModel(path1, [tag], signatureKey);
const outputArray = model1.predict([inputTensor1, inputTensor2]);
const model2 = await tf.node.loadSavedModel(path2, [tag], signatureKey);
const outputMap = model2.predict({input1: inputTensor1, input2:inputTensor2});
If you want to inspect the details of a TensorFlow SavedModel to find the model tags and signatures information (aka MetaGraphs), they can be parsed through a JavaScript helper API, similar to TensorFlow SavedModel client tool:const modelInfo = await tf.node.getMetaGraphsFromSavedModel(path);
This new feature is available in the @tensorflow/tfjs-node package version 1.3.2 and newer, for both CPU and GPU. It supports TensorFlow SavedModel trained and exported in both TensorFlow Python versions 1.x and 2.0. Besides the benefit of not needing any conversion, native execution of TensorFlow SavedModel means that you can run models with ops that are not in TensorFlow.js yet, through loading the SavedModel as a TensorFlow session in the C++ bindings.
janvier 14, 2020
—
Posted by Kangyi Zhang, Sandeep Gupta, and Brijesh Krishnaswami
TensorFlow.js is an open-source library that lets you define, train, and run machine learning models in Javascript. The library has empowered a new set of developers from the extensive JavaScript community to build and deploy machine learning models and has enabled new use cases of machine learning. For example TensorFlow.js runs in a…