UNPKG

clustering-tfjs

Version:

High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility

32 lines (31 loc) 1.13 kB
"use strict"; /** * Alternative browser adapter that uses global tf directly * This is a test to see if bypassing the import system fixes the issue */ Object.defineProperty(exports, "__esModule", { value: true }); exports.dispose = exports.tidy = exports.tensor = exports.tensor2d = void 0; // Get tf from global window object const getGlobalTf = () => { if (typeof window !== 'undefined' && window.tf) { return window.tf; } throw new Error('TensorFlow.js not found. Please load it before using this library.'); }; // Create a proxy that always gets the current global tf const tfProxy = new Proxy({}, { get(_target, prop) { const tf = getGlobalTf(); return tf[prop]; } }); exports.default = tfProxy; const tensor2d = (...args) => getGlobalTf().tensor2d(...args); exports.tensor2d = tensor2d; const tensor = (...args) => getGlobalTf().tensor(...args); exports.tensor = tensor; const tidy = (...args) => getGlobalTf().tidy(...args); exports.tidy = tidy; const dispose = (...args) => getGlobalTf().dispose(...args); exports.dispose = dispose; // Add other commonly used exports...