clustering-tfjs
Version:
High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility
25 lines (24 loc) • 895 B
JavaScript
/**
* Alternative browser adapter that uses global tf directly
* This is a test to see if bypassing the import system fixes the issue
*/
// 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];
}
});
export default tfProxy;
export const tensor2d = (...args) => getGlobalTf().tensor2d(...args);
export const tensor = (...args) => getGlobalTf().tensor(...args);
export const tidy = (...args) => getGlobalTf().tidy(...args);
export const dispose = (...args) => getGlobalTf().dispose(...args);
// Add other commonly used exports...