简体   繁体   中英

tf.keras shape ambiguation with lambda functions

I have a tf.keras.layers.Lambda layer which uses tf functions. Why is it that sometimes I have to specify output_shape=() for my Lambda call and other times I do not?

Example

freqDomain = tf.keras.layers.Lambda(tf.fft2d,
                                    output_shape=(None, tileSize, tileSize, 1))(cpxInput) # Won't work unless output_shape is specified.

This is a bug in Keras specifically around tf.ff2td right now.

Keras can't automatically calculate the output shape for fft2d functions at the moment based on the input, so output_shape needs to be specified. It's something that the developers will be working on:

https://github.com/keras-team/keras/issues/12121#issuecomment-457217337

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM