MCPcopy
hub / github.com/tensorflow/tfjs / save

Method save

tfjs-converter/src/executor/graph_model.ts:280–301  ·  view source on GitHub ↗

* Save the configuration and/or weights of the GraphModel. * * An `IOHandler` is an object that has a `save` method of the proper * signature defined. The `save` method manages the storing or * transmission of serialized data ("artifacts") that represent the * model's topology and wei

(handlerOrURL: io.IOHandler|string, config?: io.SaveConfig)

Source from the content-addressed store, hash-verified

278 * @doc {heading: 'Models', subheading: 'Classes', ignoreCI: true}
279 */
280 async save(handlerOrURL: io.IOHandler|string, config?: io.SaveConfig):
281 Promise<io.SaveResult> {
282 if (typeof handlerOrURL === 'string') {
283 const handlers = this.io.getSaveHandlers(handlerOrURL);
284 if (handlers.length === 0) {
285 throw new Error(
286 `Cannot find any save handlers for URL '${handlerOrURL}'`);
287 } else if (handlers.length > 1) {
288 throw new Error(
289 `Found more than one (${handlers.length}) save handlers for ` +
290 `URL '${handlerOrURL}'`);
291 }
292 handlerOrURL = handlers[0];
293 }
294 if (handlerOrURL.save == null) {
295 throw new Error(
296 'GraphModel.save() cannot proceed because the IOHandler ' +
297 'provided does not have the `save` attribute defined.');
298 }
299
300 return handlerOrURL.save(this.artifacts);
301 }
302
303 private addStructuredOutputNames(outputTensors: Tensor|Tensor[]) {
304 if (this.structuredOutputKeys) {

Calls 1

getSaveHandlersMethod · 0.80