Hi SunilJB,
Thanks for your reply. Unfortunately,I can only use tensorrt4 now, But now I know the true reason.
- -1 specifies that the dimension should be automatically deduced - this can only be used at most once in any given shape.
does that mean with different inputs ,the same tensor only specifies -1 once?
for example,
def rpn_graph(feature_map, anchors_per_location, anchor_stride):
shared = KL.Conv2D(512, (3, 3), padding='same', activation='relu',
strides=anchor_stride, name='rpn_conv_shared')(feature_map)
x = KL.Conv2D(2 * anchors_per_location, (1, 1), padding='valid',
activation='linear', name='rpn_class_raw')(shared)
x = KL.Permute((2,3,1))(x)
rpn_class_logits = KL.Reshape((-1, 2))(x) ######replace -1
rpn_probs = KL.Activation(
"softmax", name="rpn_class_xxx")(rpn_class_logits)
x = KL.Conv2D(anchors_per_location * 4, (1, 1), padding="valid",
activation='linear', name='rpn_bbox_pred')(shared)
x = KL.Permute((2,3,1))(x)
rpn_bbox = KL.Reshape((-1, 4))(x) ######replace -1
return [rpn_class_logits, rpn_probs, rpn_bbox]
def build_rpn_model(anchor_stride, anchors_per_location, depth):
input_feature_map = KL.Input(shape=[depth, None, None], ######remove None
name="input_rpn_feature_map")
outputs = rpn_graph(input_feature_map, anchors_per_location, anchor_stride)
return KM.Model([input_feature_map], outputs[], name="rpn_model")
class XXXX():
rpn_feature_maps = [P2, P3, P4, P5, P6]
rpn = build_rpn_model(config.RPN_ANCHOR_STRIDE,
len(config.RPN_ANCHOR_RATIOS), config.TOP_DOWN_PYRAMID_SIZE)
layer_outputs = [] # list of lists
for p in rpn_feature_maps:
layer_outputs.append(rpn([p]))
with different size input_feature_map(p2~p6) in for loop(line 30),we can only use reshape(-1,) once in rpn_graph reshape(line8 and line16)? So do you think it a good idea to build 5 rpn_model with different name(rpn_model1,rpn_model2…) and give them different input_feature_map with fixed number in reshape? And any other suggestion would be appreciated.
Thanks a lot.