tensorflow_lite Prelu不支持dims-> size = 2

时间:2018-07-23 03:59:17

标签: tensorflow tensorflow-lite

tensorflow_lite演示tflite_simple_example中,我使用我的Rnet.tflite,但出现以下错误

if (interpreter->AllocateTensors() != kTfLiteOk) {
NSLog(@"Failed to allocate tensors.");
exit(-1);
}
  

error:tensorflow / contrib / lite / kernels / activations.cc:171   input-> dims-> size!= 4(2!= 4)

     

在activations.cc中,我找到PreluPrepare()TF_LITE_ENSURE_EQ(上下文,   输入->尺寸->尺寸,4);我的输入->尺寸->大小= 2

TfLiteStatus PreluPrepare(TfLiteContext* context, TfLiteNode* node) {
TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
const TfLiteTensor* input = GetInput(context, node, 0);
TfLiteTensor* output = GetOutput(context, node, 0);
const TfLiteTensor* alpha = GetInput(context, node, 1);

output->type = input->type;

// Currently only Float32 is supported
// TODO(ycling): Support other data types.
TF_LITE_ENSURE_EQ(context, input->type, kTfLiteFloat32);
TF_LITE_ENSURE_EQ(context, alpha->type, kTfLiteFloat32);

// Currently, only support 4D input and 3D alpha with shape
// (1, 1, channels).
// TODO(impjdi): Support other cases where alpha is broadcastable
// to input.
TF_LITE_ENSURE_EQ(context, input->dims->size, 4);
TF_LITE_ENSURE_EQ(context, alpha->dims->size, 3);
TF_LITE_ENSURE_EQ(context, alpha->dims->data[0], 1);
TF_LITE_ENSURE_EQ(context, alpha->dims->data[1], 1);
TF_LITE_ENSURE_EQ(context, alpha->dims->data[2], input->dims->data[3]);

return context->ResizeTensor(context, output,
TfLiteIntArrayCopy(input->dims));
}

源代码/日志

input = Input(shape=[24, 24, 3],batch_shape=[1,24, 24, 3])
x = Conv2D(28, (3, 3), strides=1, padding='valid', name='conv1')(input)
x = PReLU(shared_axes=[1, 2], name='prelu1')(x)
x = MaxPool2D(pool_size=3,strides=2, padding='same')(x)

x = Conv2D(48, (3, 3), strides=1, padding='valid', name='conv2')(x)
x = PReLU(shared_axes=[1, 2], name='prelu2')(x)
x = MaxPool2D(pool_size=3, strides=2)(x)

x = Conv2D(64, (2, 2), strides=1, padding='valid', name='conv3')(x)
x = PReLU(shared_axes=[1, 2], name='prelu3')(x)
x = Permute((3, 2, 1))(x)
x = Flatten()(x)
x = Dense(128, name='conv4')(x)
x = PReLU( name='prelu4')(x)
classifier = Dense(2, activation='softmax', name='conv5-1')(x)
bbox_regress = Dense(4, name='conv5-2')(x)
model = Model([input], [classifier, bbox_regress])
model.load_weights(weight_path, by_name=True)

x = PReLU( name='prelu4')(x) input x->dims->size =2

我该如何解决这个问题?

0 个答案:

没有答案