Hi,
I’m trying to run TensorRT on a Keras model developed for High Energy Physics stuff.
When I compile, I get no errors from TensorRT but the parse fails at runtime.
Apparently, there’s a problem when concatenating one Input Layer (infos) to a Flatten one (flat), I tried with a Dense after infos, but got no solution.
Using TensorRT 4 C++ API, with cuda 9.0.
Here’s the function to create the model with Keras:
def model_build(img_size = 16, n_channels=20, labels=67):
hit_shapes = Input(shape=(n_channels,img_size,img_size), name=‘hit_shape_input’)
infos = Input(shape=(labels,), name=‘info_input’)
conv = Conv2D(64, (4, 4), activation='relu', padding='same', data_format="channels_first", name='conv1')(hit_shapes)
conv = Conv2D(64, (3, 3), activation='relu', padding='same', data_format="channels_first", name='conv2')(conv)
pool = MaxPooling2D(pool_size=(2, 2), padding='same', data_format="channels_first", name='pool1')(conv)
conv = Conv2D(128, (3, 3), activation='relu', padding='same', data_format="channels_first", name='conv3')(pool)
conv = Conv2D(128, (3, 3), activation='relu', padding='same', data_format="channels_first", name='conv4')(conv)
pool = MaxPooling2D(pool_size=(2, 2), padding='same', data_format="channels_first", name='pool2')(conv)
conv = Conv2D(64, (3, 3), activation='relu', padding='same', data_format="channels_first", name='conv5')(pool)
pool = MaxPooling2D(pool_size=(2, 2), padding='same', data_format="channels_first", name='pool3')(conv)
flat = Flatten(data_format='channels_first')(pool)
concat = Concatenate()([flat, infos])
dense = Dense(128, activation='sigmoid', kernel_constraint=max_norm(1.0), name='dense1')(concat)
dense = Dense(64, activation='sigmoid', kernel_constraint=max_norm(1.0), name='dense2')(dense)
pred = Dense(2, activation='softmax', kernel_constraint=max_norm(1.0), name='output')(dense)
model = Model(inputs=[hit_shapes, infos], outputs=pred)
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
return model
And here’s the error I get:
ERROR: concatenate_1/concat: all concat input tensors must have the same number of dimensions
ERROR: UFFParser: Parser error: dense1/BiasAdd: The input to the Scale Layer is required to have a minimum of 3 dimensions.