Tensorflow on Ubuntu 14.4 (64).
Here is a video version of this tutorial:
And here is the terminal commands and code used:
- sudo su
-
sudo apt-get install python-pip python-dev python-virtualenv
-
virtualenv --system-site-packages ~/tensorflow
-
source ~/tensorflow/bin/activate
-
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
Find the tenserFlow location:
-
python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'
The test project:
import tensorflow as tf
import numpy as np
# Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
x_data = np.random.rand(100).astype(np.float32)
y_data = x_data * 0.1 + 0.3
# Try to find values for W and b that compute y_data = W * x_data + b
# (We know that W should be 0.1 and b 0.3, but Tensorflow will
# figure that out for us.)
W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
b = tf.Variable(tf.zeros([1]))
y = W * x_data + b
# Minimize the mean squared errors.
loss = tf.reduce_mean(tf.square(y - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)
# Before starting, initialize the variables. We will 'run' this first.
init = tf.initialize_all_variables()
# Launch the graph.
sess = tf.Session()
sess.run(init)
# Fit the line.
for step in xrange(201):
sess.run(train)
if step % 20 == 0:
print(step, sess.run(W), sess.run(b))
# Learns best fit is W: [0.1], b: [0.3]
Start the test project:
- python -m tensorflow.test
Source pages:
I believe I ran everything prior to the sample program just fine. But on the same program I got the error message of: bash: syntax error near unexpected token `(‘
Sorry for the late response. Have you managed to solve this? Do you get a file reference/line position where this error is happening?
The root is unreadable.What should I do?
What do you mean by “unreadable”? Can you tell me the error you get, and on which step?
Hi ,
I got this Error “tensorflow-0.7.1-cp27-none-linux_x86_64.whl is not a supported wheel on this platform”. How can I solve this??
See if this helps you: https://github.com/tensorflow/tensorflow/issues/1551
hey niandrei.
first of all thanks a lot for such a lovely installation guide.
all the best for your future ventures .
Thank you very much. Have a great day!