ValueError: Input 0 of layer dense is incompatible with the layer: its rank is undefined, but the layer requires a defined rank
问题 When trying the example at https://www.tensorflow.org/tutorials/images/hub_with_keras at a local computer with tf '2.0.0-alpha0' (download, pip -download hub '0.4.0-dev' and remove !pip... lines, install tf 2, remove enable_v2_behavior , run file), it failed with ValueError: Input 0 of layer dense is incompatible with the layer: its rank is undefined, but the layer requires a defined rank. It runs fine on Google colab though. Why is this and how can it be fixed? 回答1: As proposed by @arnoegw