subpixel convolution

Hi I’m trying implement SRGAN in Keras-TF backend, and tf.depth_to_scale is not supported, so I replaced by Lambda this way:

    def pixelShuffler(inputs,scale=2):
        size = tf.shape(inputs)
        batch_size = size[0]
        h = size[1]
        w = size[2]
        c = 256
        shape_1 = [batch_size, w, h, scale, scale, 64]                       
        output = tf.reshape(inputs,shape_1)     
        output = tf.transpose(output, [0, 1, 3, 2, 4, 5])
        shape_2 = [batch_size, w*scale, h*scale, 64]
        output = tf.reshape(output,shape_2)
        return output

    def subpixel_shape(input_shape,scale=2):
        dims = [input_shape[0],
                None if input_shape[1] is None else input_shape[1] * scale,
                None if input_shape[2] is None else input_shape[2] * scale,
                64]
        output_shape = tuple(dims)
        return output_shape

    def upsample(x, number):
        x = Conv2D(256, kernel_size=3, strides=1, padding='same', name='upSampleConv2d_'+str(number))(x)
        x = Lambda(pixelShuffler, output_shape=subpixel_shape, name='Lambda_'+str(number))(x)
        #x = Conv2DTranspose(64, kernel_size=5, strides=(2, 2), padding='same',name='upSampleSubPixel_'+str(number))(x)
        x = PReLU(shared_axes=[1,2], name='upSamplePReLU_'+str(number))(x)
        return x

the network learns something. I convert it to uff, and when I try trtexe it gives me following error:

C:\Windows\system32>trtexec.exe --uff=d:/SRGAN-Keras-master/tmp_2019-11-07_123327/generator_model.uff --output=conv2d_121/Tanh --uffInput=input_11,3,256,256 --workspace=4096
&&&& RUNNING TensorRT.trtexec # trtexec.exe --uff=d:/SRGAN-Keras-master/tmp_2019-11-07_123327/generator_model.uff --output=conv2d_121/Tanh --uffInput=input_11,3,256,256 --workspace=4096
[10/07/2019-15:50:55] [I] === Model Options ===
[10/07/2019-15:50:55] [I] Format: UFF
[10/07/2019-15:50:55] [I] Model: d:/SRGAN-Keras-master/tmp_2019-11-07_123327/generator_model.uff
[10/07/2019-15:50:55] [I] Uff Inputs Layout: NCHW
[10/07/2019-15:50:55] [I] Input: input_11,3,256,256
[10/07/2019-15:50:55] [I] Output: conv2d_121/Tanh
[10/07/2019-15:50:55] [I] === Build Options ===
[10/07/2019-15:50:55] [I] Max batch: 1
[10/07/2019-15:50:55] [I] Workspace: 4096 MB
[10/07/2019-15:50:55] [I] minTiming: 1
[10/07/2019-15:50:55] [I] avgTiming: 8
[10/07/2019-15:50:55] [I] Precision: FP32
[10/07/2019-15:50:55] [I] Calibration:
[10/07/2019-15:50:55] [I] Safe mode: Disabled
[10/07/2019-15:50:55] [I] Save engine:
[10/07/2019-15:50:55] [I] Load engine:
[10/07/2019-15:50:55] [I] Inputs format: fp32:CHW
[10/07/2019-15:50:55] [I] Outputs format: fp32:CHW
[10/07/2019-15:50:55] [I] Input build shapes: model
[10/07/2019-15:50:55] [I] === System Options ===
[10/07/2019-15:50:55] [I] Device: 0
[10/07/2019-15:50:55] [I] DLACore:
[10/07/2019-15:50:55] [I] Plugins:
[10/07/2019-15:50:55] [I] === Inference Options ===
[10/07/2019-15:50:55] [I] Batch: 1
[10/07/2019-15:50:55] [I] Iterations: 10 (200 ms warm up)
[10/07/2019-15:50:55] [I] Duration: 10s
[10/07/2019-15:50:55] [I] Sleep time: 0ms
[10/07/2019-15:50:55] [I] Streams: 1
[10/07/2019-15:50:55] [I] Spin-wait: Disabled
[10/07/2019-15:50:55] [I] Multithreading: Enabled
[10/07/2019-15:50:55] [I] CUDA Graph: Disabled
[10/07/2019-15:50:55] [I] Skip inference: Disabled
[10/07/2019-15:50:55] [I] Input inference shapes: model
[10/07/2019-15:50:55] [I] === Reporting Options ===
[10/07/2019-15:50:55] [I] Verbose: Disabled
[10/07/2019-15:50:55] [I] Averages: 10 inferences
[10/07/2019-15:50:55] [I] Percentile: 99
[10/07/2019-15:50:55] [I] Dump output: Disabled
[10/07/2019-15:50:55] [I] Profile: Disabled
[10/07/2019-15:50:55] [I] Export timing to JSON file:
[10/07/2019-15:50:55] [I] Export profile to JSON file:
[10/07/2019-15:50:55] [I]
[10/07/2019-15:50:56] [E] [TRT] UffParser: Parser error: upSamplePReLU_1/mul: Invalid scale mode, nbWeights: 64
[10/07/2019-15:50:56] [E] Failed to parse uff file
[10/07/2019-15:50:56] [E] Parsing model failed
[10/07/2019-15:50:56] [E] Engine could not be created
&&&& FAILED TensorRT.trtexec # trtexec.exe --uff=d:/SRGAN-Keras-master/tmp_2019-11-07_123327/generator_model.uff --output=conv2d_121/Tanh --uffInput=input_11,3,256,256 --workspace=4096


when I replace Lambda by Conv2Transpose everything works well.

Any idea what is wrong?

thanks

Filip

Could you please let us know if you are still facing this issue?

Thanks