Stack Exchange
Tensorflow 2.2.0-rc4 AttributeError: module 'tensorflow.compat.v1' has no attribute 'contrib' in Spyder?
This is my code in Spyder.
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior() 



# Building the seq2seq model
def seq2seq_model(inputs, targets, keep_prob, batch_size, sequence_length, answers_num_words, questions_num_words, encoder_embedding_size, decoder_embedding_size, rnn_size, num_layers, questionswords2int):
    encoder_embedded_input = tf.contrib.layers.embed_sequence(inputs,
                                                              answers_num_words + 1,
                                                              encoder_embedding_size,
                                                              initializer = tf.random_uniform_initializer(0, 1))
    encoder_state = encoder_rnn(encoder_embedded_input, rnn_size, num_layers, keep_prob, sequence_length)
    preprocessed_targets = preprocess_targets(targets, questionswords2int, batch_size)
    decoder_embeddings_matrix = tf.Variable(tf.random_uniform([questions_num_words + 1, decoder_embedding_size], 0, 1))
    decoder_embedded_input = tf.nn.embedding_lookup(decoder_embeddings_matrix, preprocessed_targets)
    training_predictions, test_predictions = decoder_rnn(decoder_embedded_input,
                                                         decoder_embeddings_matrix,
                                                         encoder_state,
                                                         questions_num_words,
                                                         sequence_length,
                                                         rnn_size,
                                                         num_layers,
                                                         questionswords2int,
                                                         keep_prob,
                                                         batch_size)
    return training_predictions, test_predictions

I'm using Ubuntu 18.04
    $ python3
 Python 3.8.3 (default, Jul  2 2020, 16:21:59)  [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    >>> tf.__version__ '
    >>> 2.2.0-rc4'

I know tf.contrib was removed from TensorFlow
I have found some solution in here   but couldn't solve the problem

Finally I understood there is no way to continue with contrib in tensorflow 2 and python 3.8.
And here I have downgrade my python version to pythone 3.5 and tensorflow 1.0.
Here is the steps I followed
First step: I have create a new environment with python version 3.5
conda create --name env1 pip python=3.5 parso=0.7

Second step: Activated my environment
conda activate env1

And finally install tensorflow 1.0
pip install tensorflow==1.0

This is worked for me.
