title: Using tf.compat.v1.variable_scope produces an error - Tensorflow has no attribute variable_scope
body: <p>I searched for possible solutions and everywhere it has been advised to use <code>tf.compat.v1.variable_scope</code>. I did the same, and yet I am getting the error:</p>
  <pre><code>module 'tensorflow' has no attribute 'variable_scope'
  </code></pre>
  <p>I am using google colab.</p>
  <p>My code:</p>
  <pre><code>import tensorflow as tf #version - 2.3.0
  with tf.compat.v1.variable_scope(self.name):
              self._build()
  
  </code></pre>
  <p>Error:</p>
  <pre><code>---&gt; 45         with tf.compat.v1.variable_scope(self.name):
       46             self._build()
       47 
  
  AttributeError: module 'tensorflow' has no attribute 'variable_scope'
  
  </code></pre>
  <p>Any suggestions on how to get rid of this error?
  My Tensorflow version is 2.3.0.</p>
  <p>Edit:</p>
  <p>This is the suggestion in <a href="https://www.tensorflow.org/guide/migrate" rel="nofollow noreferrer">Migrate your TensorFlow 1 code to TensorFlow 2</a> as suggested by Astrian_72954:</p>
  <blockquote>
  <p>Every v1.variable_scope should be converted to a Python object.
  Typically this will be one of:</p>
  <pre><code>tf.keras.layers.Layer 
  tf.keras.Model
  tf.Module
  </code></pre>
  </blockquote>
  <p>I did not understand this solution. Can someone explain what is meant by converting to Python object?</p>