Repository: TheAlgorithms/Python

Issue:
Reenable files when TensorFlow supports the current Python
As discussed in #3926, the following files do not have `.py` extensions because [TensorFlow does not yet support the current Python](https://github.com/tensorflow/tensorflow/issues/44485).
* dynamic_programming/k_means_clustering_tensorflow.py_tf
* machine_learning/lstm/lstm_prediction.py_tf
* neural_network/gan.py_tf
* neural_network/input_data.py_tf

TODO: Restore the `.py` file extensions and ensure our tests pass when TensorFlow supports the current Python.


Discussion:
I understood the issue , Could please me to this issue @cclauss 
We do not assign issues.  We review pull requests.
hello @cclauss 
tensorflow 2 as for now doesn't support Python 3.9.
so I'll change them once tensorflow 2 is compatible with python 3.9.

Hello can you please assign me this issue?
This repo does not assign issues.  We review pull requests.
@cclauss  Sir, m new to open source and i want to start. I want to contribute in your organization. Please guide me how to start

hey i am new to git hub. can you direct me how shll i work on this issue?

Yes.  Scroll to the top of this page and click the link __TensorFlow does not yet support the current Python.__. Once that issue is fixed then this issue can be worked on.
The TensorFlow 2.5 ___release candidate 0___ is out so we should be able to fix this issue soon...
https://github.com/tensorflow/tensorflow/releases
so cool
We are getting close because TensorFlow 2.5 release candidate 2 is now available…
https://github.com/tensorflow/tensorflow/releases
Python 3.11 is finally supported.  https://github.com/tensorflow/tensorflow/releases
@tianyizheng02 or @MaximSmolskiy Interested?
https://github.com/search?q=repo%3ATheAlgorithms%2FPython%20tensorflow&type=code

Resolving patch:
diff --git a/dynamic_programming/k_means_clustering_tensorflow.py_tf b/dynamic_programming/k_means_clustering_tensorflow.py
similarity index 98%
rename from dynamic_programming/k_means_clustering_tensorflow.py_tf
rename to dynamic_programming/k_means_clustering_tensorflow.py
--- a/dynamic_programming/k_means_clustering_tensorflow.py_tf
+++ b/dynamic_programming/k_means_clustering_tensorflow.py
@@ -1,9 +1,10 @@
-import tensorflow as tf
 from random import shuffle
+
+import tensorflow as tf
 from numpy import array
 
 
-def TFKMeansCluster(vectors, noofclusters):
+def tf_k_means_cluster(vectors, noofclusters):
     """
     K-Means Clustering using TensorFlow.
     'vectors' should be a n*k 2-D NumPy array, where n is the number
@@ -30,7 +31,6 @@ def TFKMeansCluster(vectors, noofclusters):
     graph = tf.Graph()
 
     with graph.as_default():
-
         # SESSION OF COMPUTATION
 
         sess = tf.Session()
@@ -95,8 +95,7 @@ def TFKMeansCluster(vectors, noofclusters):
         # iterations. To keep things simple, we will only do a set number of
         # iterations, instead of using a Stopping Criterion.
         noofiterations = 100
-        for iteration_n in range(noofiterations):
-
+        for _ in range(noofiterations):
             ##EXPECTATION STEP
             ##Based on the centroid locations till last iteration, compute
             ##the _expected_ centroid assignments.
diff --git a/neural_network/input_data.py_tf b/neural_network/input_data.py
similarity index 83%
rename from neural_network/input_data.py_tf
rename to neural_network/input_data.py
--- a/neural_network/input_data.py_tf
+++ b/neural_network/input_data.py
@@ -21,13 +21,10 @@
 import collections
 import gzip
 import os
+import urllib
 
 import numpy
-from six.moves import urllib
-from six.moves import xrange  # pylint: disable=redefined-builtin
-
-from tensorflow.python.framework import dtypes
-from tensorflow.python.framework import random_seed
+from tensorflow.python.framework import dtypes, random_seed
 from tensorflow.python.platform import gfile
 from tensorflow.python.util.deprecation import deprecated
 
@@ -46,16 +43,16 @@ def _read32(bytestream):
 def _extract_images(f):
     """Extract the images into a 4D uint8 numpy array [index, y, x, depth].
 
-  Args:
-    f: A file object that can be passed into a gzip reader.
+    Args:
+      f: A file object that can be passed into a gzip reader.
 
-  Returns:
-    data: A 4D uint8 numpy array [index, y, x, depth].
+    Returns:
+      data: A 4D uint8 numpy array [index, y, x, depth].
 
-  Raises:
-    ValueError: If the bytestream does not start with 2051.
+    Raises:
+      ValueError: If the bytestream does not start with 2051.
 
-  """
+    """
     print("Extracting", f.name)
     with gzip.GzipFile(fileobj=f) as bytestream:
         magic = _read32(bytestream)
@@ -86,17 +83,17 @@ def _dense_to_one_hot(labels_dense, num_classes):
 def _extract_labels(f, one_hot=False, num_classes=10):
     """Extract the labels into a 1D uint8 numpy array [index].
 
-  Args:
-    f: A file object that can be passed into a gzip reader.
-    one_hot: Does one hot encoding for the result.
-    num_classes: Number of classes for the one hot encoding.
+    Args:
+      f: A file object that can be passed into a gzip reader.
+      one_hot: Does one hot encoding for the result.
+      num_classes: Number of classes for the one hot encoding.
 
-  Returns:
-    labels: a 1D uint8 numpy array.
+    Returns:
+      labels: a 1D uint8 numpy array.
 
-  Raises:
-    ValueError: If the bystream doesn't start with 2049.
-  """
+    Raises:
+      ValueError: If the bystream doesn't start with 2049.
+    """
     print("Extracting", f.name)
     with gzip.GzipFile(fileobj=f) as bytestream:
         magic = _read32(bytestream)
@@ -115,8 +112,8 @@ def _extract_labels(f, one_hot=False, num_classes=10):
 class _DataSet:
     """Container class for a _DataSet (deprecated).
 
-  THIS CLASS IS DEPRECATED.
-  """
+    THIS CLASS IS DEPRECATED.
+    """
 
     @deprecated(
         None,
@@ -135,21 +132,21 @@ def __init__(
     ):
         """Construct a _DataSet.
 
-    one_hot arg is used only if fake_data is true.  `dtype` can be either
-    `uint8` to leave the input as `[0, 255]`, or `float32` to rescale into
-    `[0, 1]`.  Seed arg provides for convenient deterministic testing.
-
-    Args:
-      images: The images
-      labels: The labels
-      fake_data: Ignore inages and labels, use fake data.
-      one_hot: Bool, return the labels as one hot vectors (if True) or ints (if
-        False).
-      dtype: Output image dtype. One of [uint8, float32]. `uint8` output has
-        range [0,255]. float32 output has range [0,1].
-      reshape: Bool. If True returned images are returned flattened to vectors.
-      seed: The random seed to use.
-    """
+        one_hot arg is used only if fake_data is true.  `dtype` can be either
+        `uint8` to leave the input as `[0, 255]`, or `float32` to rescale into
+        `[0, 1]`.  Seed arg provides for convenient deterministic testing.
+
+        Args:
+          images: The images
+          labels: The labels
+          fake_data: Ignore inages and labels, use fake data.
+          one_hot: Bool, return the labels as one hot vectors (if True) or ints (if
+            False).
+          dtype: Output image dtype. One of [uint8, float32]. `uint8` output has
+            range [0,255]. float32 output has range [0,1].
+          reshape: Bool. If True returned images are returned flattened to vectors.
+          seed: The random seed to use.
+        """
         seed1, seed2 = random_seed.get_seed(seed)
         # If op level seed is not set, use whatever graph level seed is returned
         numpy.random.seed(seed1 if seed is None else seed2)
@@ -206,8 +203,8 @@ def next_batch(self, batch_size, fake_data=False, shuffle=True):
             else:
                 fake_label = 0
             return (
-                [fake_image for _ in xrange(batch_size)],
-                [fake_label for _ in xrange(batch_size)],
+                [fake_image for _ in range(batch_size)],
+                [fake_label for _ in range(batch_size)],
             )
         start = self._index_in_epoch
         # Shuffle for the first epoch
@@ -250,19 +247,19 @@ def next_batch(self, batch_size, fake_data=False, shuffle=True):
 def _maybe_download(filename, work_directory, source_url):
     """Download the data from source url, unless it's already here.
 
-  Args:
-      filename: string, name of the file in the directory.
-      work_directory: string, path to working directory.
-      source_url: url to download from if file doesn't exist.
+    Args:
+        filename: string, name of the file in the directory.
+        work_directory: string, path to working directory.
+        source_url: url to download from if file doesn't exist.
 
-  Returns:
-      Path to resulting file.
-  """
+    Returns:
+        Path to resulting file.
+    """
     if not gfile.Exists(work_directory):
         gfile.MakeDirs(work_directory)
     filepath = os.path.join(work_directory, filename)
     if not gfile.Exists(filepath):
-        urllib.request.urlretrieve(source_url, filepath)
+        urllib.request.urlretrieve(source_url, filepath)  # noqa: S310
         with gfile.GFile(filepath) as f:
             size = f.size()
         print("Successfully downloaded", filename, size, "bytes.")
@@ -328,7 +325,8 @@ def fake():
 
     if not 0 <= validation_size <= len(train_images):
         raise ValueError(
-            f"Validation size should be between 0 and {len(train_images)}. Received: {validation_size}."
+            f"Validation size should be between 0 and {len(train_images)}. "
+            f"Received: {validation_size}."
         )
 
     validation_images = train_images[:validation_size]
@@ -336,7 +334,7 @@ def fake():
     train_images = train_images[validation_size:]
     train_labels = train_labels[validation_size:]
 
-    options = dict(dtype=dtype, reshape=reshape, seed=seed)
+    options = {"dtype": dtype, "reshape": reshape, "seed": seed}
 
     train = _DataSet(train_images, train_labels, **options)
     validation = _DataSet(validation_images, validation_labels, **options)


Test patch: