The serialized artifacts of a model, including topology and weights.

The modelTopology, trainingConfig, weightSpecs and weightData fields of this interface are optional, in order to support topology- or weights-only saving and loading.

Note this interface is used internally in IOHandlers. For the file format written to disk as model.json, see ModelJSON.

interface ModelArtifacts {
    convertedBy?: null | string;
    format?: string;
    generatedBy?: string;
    getWeightStream?: (() => ReadableStream<ArrayBuffer>);
    initializerSignature?: {};
    modelInitializer?: {};
    modelTopology?: {} | ArrayBuffer;
    signature?: {};
    trainingConfig?: TrainingConfig;
    userDefinedMetadata?: {
        [key: string]: {};
    };
    weightData?: WeightData;
    weightSpecs?: WeightsManifestEntry[];
}

Properties

convertedBy?: null | string

What library or tool is responsible for converting the original model to this format, applicable only if the model is output by a converter.

Used for debugging purposes. E.g., 'TensorFlow.js Converter v1.0.0'.

A value of null means the model artifacts are generated without any conversion process (e.g., saved directly from a TensorFlow.js tf.LayersModel instance.)

format?: string

Hard-coded format name for models saved from TensorFlow.js or converted by TensorFlow.js Converter.

generatedBy?: string

What library is responsible for originally generating this artifact.

Used for debugging purposes. E.g., 'TensorFlow.js v1.0.0'.

getWeightStream?: (() => ReadableStream<ArrayBuffer>)

Returns a stream of the weights. Some models are too large to fit in V8's memory heap, and getWeightStream loads their weights without storing them all in memory at the same time.

Type declaration

    • (): ReadableStream<ArrayBuffer>
    • Returns a stream of the weights. Some models are too large to fit in V8's memory heap, and getWeightStream loads their weights without storing them all in memory at the same time.

      Returns ReadableStream<ArrayBuffer>

initializerSignature?: {}

Inputs and outputs signature for model initializer.

Type declaration

    modelInitializer?: {}

    Initializer for the model.

    Type declaration

      modelTopology?: {} | ArrayBuffer

      Model topology.

      For Keras-style tf.Models, this is a JSON object. For TensorFlow-style models (e.g., SavedModel), this is the JSON encoding of the GraphDef protocol buffer.

      Type declaration

        signature?: {}

        Inputs and outputs signature for saved model.

        Type declaration

          trainingConfig?: TrainingConfig

          Serialized configuration for the model's training.

          userDefinedMetadata?: {
              [key: string]: {};
          }

          User-defined metadata about the model.

          Type declaration

          • [key: string]: {}
            weightData?: WeightData

            Binary buffer(s) for all weight values in the order specified by weightSpecs. This may be a single ArrayBuffer of all the weights concatenated together or an Array of ArrayBuffers containing the weights (weights may be sharded across multiple ArrayBuffers).

            weightSpecs?: WeightsManifestEntry[]

            Weight specifications.

            This corresponds to the weightsData below.