title: How to set optimizer in tensorflow 2.4.1
body: <p>I follow a code to learn image classification. However, this code uses a structure with the optimizer in the compile function:</p>
  <pre><code>optimizer=optimizers.Adam(lr=lr)
  </code></pre>
  <p>But I obtain an error:</p>
  <pre><code>File &quot;C:\Users\jucar\PycharmProjects\AIRecProject\Scode.py&quot;, line 69, in &lt;module&gt;
  optimizer=optimizers.Adam(lr=lr),NameError: name 'optimizers' is not defined
  </code></pre>
  <p>I changed the structure following a similar solution of this problem with:</p>
  <pre><code>optimizer='adam'(lr=lr)
  </code></pre>
  <p>But this error is presented:</p>
  <pre><code>File &quot;C:\Users\jucar\PycharmProjects\AIRecProject\Scode.py&quot;, line 69, in &lt;module&gt;
  optimizer='adam'(lr=lr),TypeError: 'str' object is not callable
  </code></pre>
  <p>I was looking for the information available on Keras and TensorFlow, and this information is provided</p>
  <pre><code>tf.keras.optimizers.Adam(
  learning_rate=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-07, amsgrad=False,
  name='Adam', **kwargs
  </code></pre>
  <p>)</p>
  <p>Therefore I use this:</p>
  <pre><code>from tensorflow.python.keras import optimizers as opt
  </code></pre>
  <p>and later:</p>
  <pre><code>opt = opt(learning_rate=0.001, gradient_aggregator=None, gradient_transformers=None)
  
  SD.compile(loss='categorical_crossentropy',
          optimizer=opt,
          metrics=['accuracy'])
  </code></pre>
  <p>With this error:</p>
  <pre><code>File &quot;C:\Users\jucar\PycharmProjects\AIRecProject\Scode.py&quot;, line 67, in &lt;module&gt;
  opt = opt(learning_rate=0.001)TypeError: 'module' object is not callable
  </code></pre>
  <p>And I changed to:</p>
  <pre><code>opt = opt.Adam(learning_rate=0.001)
  </code></pre>
  <p>Obtaining this error:</p>
  <pre><code>File &quot;C:\Users\jucar\PycharmProjects\AIRecProject\Scode.py&quot;, line 67, in &lt;module&gt;
  opt = opt.Adam(learning_rate=0.001)
  AttributeError: module 'tensorflow.python.keras.optimizers' has no attribute 'Adam'
  </code></pre>
  <p>How I can solve this issue?</p>