使用asyncStorageIO API加载模型时出错

时间:2020-06-24 06:23:30

标签: tensorflow.js

要获得社区的帮助,我们鼓励使用Stack Overflow和tensorflow.js标签。

TensorFlow.js版本

0.3.0

浏览器版本

React Native:v0.61.5

描述问题或功能要求

使用AsyncStorageIO API加载模型时出现以下错误。

Row too big to fit into CursorWindow requiredPos=0, totalRows=1
* http://192.168.1.7:19001/index.bundle?platform=android&dev=true&minify=false&hot=false:203062:24 in convertError
* [native code]:null in map
- node_modules/@react-native-community/async-storage/src/AsyncStorage.native.js:97:32 in RCTAsyncStorage.multiGet$argument_1
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:483:4 in __invokeCallback
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:28 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:17 in __guard$argument_0
* [native code]:null in invokeCallbackAndReturnFlushedQueue

在我的项目中,我有一个带有json和权重的模型,已使用bundleStorageIO API加载了该模型。然后,我使用给定的代码更新模型,并使用asyncStorageIO API保存它。流程进行得很好。但是,我尝试使用asyncStorageIO API加载模型,但出现了先前描述的错误。

 const optimizer = tf.train.adam();
      model.compile({
        optimizer: optimizer,
        loss: "categoricalCrossentropy",
        metrics: ["accuracy"],
      });
model
        .trainOnBatch(
          tf
            .tensor2d(imageTensors, [numOfElems, 784])
            .reshape([numOfElems, 28, 28, 1]),
          tf.tensor2d(labelTensors, [numOfElems, 10]).reshape([numOfElems, 10])
        )
        .then((d) => {
          console.log("Model updated");
          model
            .save(asyncStorageIO("mnist-model"))
            .then((res) => console.log("Model Saved", res))
            .catch((e) => console.log(e));
        });

0 个答案:

没有答案