I try to create a convolution layer with same padding.
conv1 = network.add_convolution(input=input_tensor, num_output_maps=16, kernel_shape=(3, 3), kernel=conv1_w,bias=trt.Weights())
But there is no padding in the argument list.And I find there is a add_padding function in the network class but fail to implement it correctly.
Can some one show me a right way to implement a padded convolution.
Thanks
NVESJ
March 21, 2019, 9:01pm
2
Hello,
Using the add_padding function in the network class creates an IPaddingLayer after the convolutional layer.
Instead, you can set the pre-padding and post-padding variables of the IConvlutionLayer.
See https://docs.nvidia.com/deeplearning/sdk/tensorrt-api/python_api/infer/Graph/Layers.html#iconvolutionlayer
@NVESJ
input_tensor = network.add_input(name="input_tensor", dtype=trt.float32, shape=(3,416,416))
conv1_w = weights['module_list.0.conv_0.weight'].numpy()
padding_1 = network.add_padding(input=input_tensor,pre_padding=(2,2),post_padding=(0,0))
conv1 = network.add_convolution(input=padding_1.get_output(0), num_output_maps=16, kernel_shape=(3, 3), kernel=conv1_w,bias=trt.Weights())
conv1.stride = (1, 1)
I implement as above.But according to your answer I should add_padding after convolution layer should I
implement like:
input_tensor = network.add_input(name="input_tensor", dtype=trt.float32, shape=(3,416,416))
conv1_w = weights['module_list.0.conv_0.weight'].numpy()
conv1 = network.add_convolution(input=padding_1.get_output(0), num_output_maps=16, kernel_shape=(3, 3), kernel=conv1_w,bias=trt.Weights())
conv1.stride = (1, 1)
padding_1 = network.add_padding(input=conv1.get_output(0),pre_padding=(2,2),post_padding=(0,0))
NVESJ
March 22, 2019, 4:56pm
4
Hello,
I apologize, you are right you should add the IPaddingLayer “before” your IConvolutionLayer.
Are you facing there any further issues by doing so?