face-api/src/common/disposeUnusedWeightTensors.ts

10 lines
284 B
TypeScript
Raw Normal View History

2020-08-18 13:54:53 +02:00
import { ParamMapping } from './types';
export function disposeUnusedWeightTensors(weightMap: any, paramMappings: ParamMapping[]) {
Object.keys(weightMap).forEach(path => {
if (!paramMappings.some(pm => pm.originalPath === path)) {
weightMap[path].dispose()
}
})
}