我当前使用以下代码在tfjs
中加载一个模型。我试图通过使用CloudFlare的Cacheneneneba API将文件缓存到更接近调用模型的位置来优化模型。有没有一种方法可以让我在加载操作中拦截fetch调用,以缓存模型数据并将从缓存中提取的数据加载到模型中?
当前代码:
const model = await tf.loadLayersModel("model_url_from_gcp")
尝试实现:
// Will load data from cache if data is cached, else will fetch from URL and cache
const load_data = cache.get("model_url_from_gcp")
// Will load cached data into Model instead of using a URL
const model = await tf.loadLayersModel(load_data)
TFHub中的GraphModels是否也有同样的方法?
const model = await tf.loadGraphModel("some_tfhub_url", { fromTFHub: true })
对于TensorFlow.js使用LocalStorage或IndexDB,请参阅以下文档:
IndexDB:https://www.tensorflow.org/js/guide/save_load#indexeddb_browser_only
本地存储:https://www.tensorflow.org/js/guide/save_load#local_storage_browser_only