mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Reenable files when TensorFlow supports the current Python (#8602)
* Remove python_version < "3.11" for tensorflow * Reenable neural_network/input_data.py_tf * updating DIRECTORY.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Try to fix ruff * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Try to fix ruff * Try to fix ruff * Try to fix ruff * Try to fix pre-commit * Try to fix * Fix * Fix * Reenable dynamic_programming/k_means_clustering_tensorflow.py_tf * updating DIRECTORY.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Try to fix ruff --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -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.
|
Reference in New Issue
Block a user