Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
install TensorFlow on Windows 10 Bash (include graphiclib)

install TensorFlow on Windows 10 Bash (include graphiclib)

1. install packages

sudo apt-get update
sudo apt-get install -y --no-install-recommends \
        build-essential \
        libfreetype6-dev \
        libpng12-dev \
        libzmq3-dev \
        pkg-config \
        python3-dev \
        python3-numpy \
        python3-pip \
        python3-scipy \
        python3-matplotlib \
        python3-pandas \
        python3-tk \
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*

2. install packages with pip

sudo pip3 install seaborn
sudo pip3 install --upgrade $TF_BINARY_URL
  • if install python3.5 and occur pip3 error
sudo pip3 install --upgrade pip
sudo pip3 install setuptools
sudo pip3 install seaborn
sudo pip3 install --upgrade $TF_BINARY_URL

3. edit .bashrc

  • adding environment variable DISPLAY
export DISPLAY=:0

4. install X-Server on Host

5. run test code

import numpy as np

num_puntos = 2000
conjunto_puntos = []
for i in range(num_puntos):
   if np.random.random() > 0.5:
     conjunto_puntos.append([np.random.normal(0.0, 0.9), np.random.normal(0.0, 0.9)])
     conjunto_puntos.append([np.random.normal(3.0, 0.5), np.random.normal(1.0, 0.5)])

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

df = pd.DataFrame({"x": [v[0] for v in conjunto_puntos],
        "y": [v[1] for v in conjunto_puntos]})
sns.lmplot("x", "y", data=df, fit_reg=False, size=6)

import tensorflow as tf

vectors = tf.constant(conjunto_puntos)
k = 4
centroides = tf.Variable(tf.slice(tf.random_shuffle(vectors),[0,0],[k,-1]))

expanded_vectors = tf.expand_dims(vectors, 0)
expanded_centroides = tf.expand_dims(centroides, 1)

assignments = tf.argmin(tf.reduce_sum(tf.square(tf.sub(expanded_vectors, expanded_centroides)), 2), 0)

means = tf.concat(0, [tf.reduce_mean(tf.gather(vectors, tf.reshape(tf.where( tf.equal(assignments, c)),[1,-1])), reduction_indices=[1]) for c in range(k)])

update_centroides = tf.assign(centroides, means)

init_op = tf.initialize_all_variables()

sess = tf.Session()

for step in range(100):
   _, centroid_values, assignment_values =[update_centroides, centroides, assignments])

data = {"x": [], "y": [], "cluster": []}

for i in range(len(assignment_values)):

df = pd.DataFrame(data)
sns.lmplot("x", "y", data=df, fit_reg=False, size=6, hue="cluster", legend=False)
Copy link

should work just as well in a virtualenv yes?

Copy link

Seems the test is not working,

Traceback (most recent call last):
sns.lmplot("x", "y", data=df, fit_reg=False, size=6)
File "/usr/local/lib/python3.4/dist-packages/seaborn/", line 590, in lmplot
facets.map_dataframe(regplot, x, y, **regplot_kws)
File "/usr/local/lib/python3.4/dist-packages/seaborn/", line 805, in map_dataframe
data_ijk = data_ijk.dropna()
File "/usr/lib/python3/dist-packages/pandas/core/", line 2411, in dropna
count = agg_obj.count(axis=agg_axis)
File "/usr/lib/python3/dist-packages/pandas/core/", line 3859, in count
counts = notnull(frame.values).sum(1)
File "/usr/lib/python3/dist-packages/pandas/core/", line 276, in notnull
return -res
TypeError: The numpy boolean negative, the - operator, is not supported, use the ~ operator or the logical_not function instead.

Copy link

am not able to download tensorflow using this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment