fversaci/WaveTF

Exception encountered when calling layer "haar_wave_layer2d_5" (type HaarWaveLayer2D).

tanvir9476 opened this issue · 2 comments


TypeError: Exception encountered when calling layer "haar_wave_layer2d_5" (type HaarWaveLayer2D).

in user code:

    File "/usr/local/lib/python3.7/dist-packages/wavetf/_base_wavelets.py", line 107, in call  *
        self.nx, self.ny = map(lambda x: math.ceil(x / 2), [self.ox, self.oy])

    TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'


Call arguments received:
  • batch=tf.Tensor(shape=(None, None, None, 64), dtype=float32)


I've been trying to use the DWT and IDWT layer inside a residual module:

def wavelet_residual_block(block_input, num_filters, momentum=0.8, wave_kern='db2'):

    x = WaveTFFactory().build(wave_kern, dim = 2)(block_input) ##
    x = BatchNormalization()(x) ##

    x = Conv2D(num_filters, kernel_size=3, padding='same')(x)
    x = BatchNormalization(momentum=momentum)(x)
    x = PReLU(shared_axes=[1, 2])(x)
    x = Conv2D(num_filters, kernel_size=3, padding='same')(x)
    x = BatchNormalization(momentum=momentum)(x)
    x = WaveTFFactory().build(wave_kern, dim = 2, inverse = True)(x)

    x = Add()([block_input, x])
    return x

The model was used on an image dataset.

What's the shape of your input tensors (block_input and x). The library expects a 4-dimensional tensor with the last three components defined (e.g., [None, 128, 128, 3] for RGB 128x128 pixel images)

P.S. Note that this is not a discrete Fourier transform (DFT) library, but a Wavelet one.

I think it's (None, None, None, 64); that's why it was throwing an error. Didn't know the library expected tensors with last 3 components explicitly defined. Thanks for the clarification.