Tensorflow 将Keras-Gru模型转换为tf-lite

Tensorflow 将Keras-Gru模型转换为tf-lite,tensorflow,keras,sequence,tensorflow-lite,gated-recurrent-unit,Tensorflow,Keras,Sequence,Tensorflow Lite,Gated Recurrent Unit,我正在尝试将我的定制Keras模型(带有两个双向GRU层)转换为tf lite,以便在移动设备上使用。我将模型转换为protobuff格式,并尝试使用TensorFlow提供的代码进行转换: converter = tf.lite.TFLiteConverter.from_frozen_graph('gru.pb', input_arrays=['input_array'], output_arrays=['output_array']) tflite_model = converter.con

我正在尝试将我的定制Keras模型(带有两个双向GRU层)转换为tf lite,以便在移动设备上使用。我将模型转换为protobuff格式,并尝试使用TensorFlow提供的代码进行转换:

converter = tf.lite.TFLiteConverter.from_frozen_graph('gru.pb', input_arrays=['input_array'], output_arrays=['output_array'])
tflite_model = converter.convert()
当我执行此操作时,它会运行一段时间,然后出现以下错误:

F tensorflow/lite/toco/tooling_util.cc:1455] Should not get here: 5
因此,我查找了该文件,其中说明了以下内容:

void MakeArrayDims(int num_dims, int batch, int height, int width, int depth,
                   std::vector<int>* out_dims) {
  CHECK(out_dims->empty());
  if (num_dims == 0) {
    return;
  } else if (num_dims == 1) {
    CHECK_EQ(batch, 1);
    *out_dims = {depth};
  } else if (num_dims == 2) {
    *out_dims = {batch, depth};
  } else if (num_dims == 3) {
    CHECK_EQ(batch, 1);
    *out_dims = {height, width, depth};
  } else if (num_dims == 4) {
    *out_dims = {batch, height, width, depth};
  } else {
    LOG(FATAL) << "Should not get here: " << num_dims;
  }
}
void MakeArrayDims(int num_dims,int batch,int height,int width,int depth,
标准::矢量*输出(尺寸){
签出(out_dims->empty());
如果(num_dims==0){
返回;
}else if(num_dims==1){
检查均衡器(批次,1);
*out_dims={depth};
}else if(num_dims==2){
*out_dims={batch,depth};
}else if(num_dims==3){
检查均衡器(批次,1);
*out_dims={高度、宽度、深度};
}else if(num_dims==4){
*out_dims={批次、高度、宽度、深度};
}否则{

LOG(致命)TFLite似乎只接受维度为Not的张量,但我已经有一段时间没有看了。TFLite似乎只接受维度为Not的张量,但我已经有一段时间没有看了。