MCPcopy Create free account
hub / github.com/tensorflow/tfjs / loadWeights

Method loadWeights

tfjs-node/src/io/file_system.ts:184–200  ·  view source on GitHub ↗
(
      weightsManifest: tf.io.WeightsManifestConfig,
      path: string)

Source from the content-addressed store, hash-verified

182 }
183
184 private async loadWeights(
185 weightsManifest: tf.io.WeightsManifestConfig,
186 path: string): Promise<[tf.io.WeightsManifestEntry[], ArrayBuffer]> {
187 const dirName = dirname(path);
188 const buffers: Buffer[] = [];
189 const weightSpecs: tf.io.WeightsManifestEntry[] = [];
190 for (const group of weightsManifest) {
191 for (const path of group.paths) {
192 const weightFilePath = join(dirName, path);
193 const buffer = await readFile(weightFilePath)
194 .catch(doesNotExistHandler('Weight file'));
195 buffers.push(buffer);
196 }
197 weightSpecs.push(...group.weights);
198 }
199 return [weightSpecs, toArrayBuffer(buffers)];
200 }
201
202 /**
203 * For each item in `this.path`, creates a directory at the path or verify

Callers 2

loadBinaryModelMethod · 0.95
loadJSONModelMethod · 0.95

Calls 3

toArrayBufferFunction · 0.90
doesNotExistHandlerFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected