AttributeError: module 'tensorflow' has no attribute 'contrib'

The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:

  • https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  • https://github.com/tensorflow/addons
  • https://github.com/tensorflow/io (for I/O related ops)
    If you depend on functionality not listed there, please file an issue.

解决办法:
笔者简单地pip uninstall tensorflow
装回1.X的版本