Skip to content
This repository was archived by the owner on Jan 1, 2021. It is now read-only.

Add setup instructions for Ubuntu #47

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ examples/checkpoints/*
examples/chatbot/processed/*
examples/chatbot/checkpoints/*
examples/chatbot/data_analysis.py
examples/data/*
examples/graphs/*
examples/test/*

assignments/chatbot/processed/*

env/*
4 changes: 2 additions & 2 deletions examples/02_feed_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
c = a + b # short for tf.add(a, b)

with tf.Session() as sess:
# print(sess.run(c)) # InvalidArgumentError because a doesn’t have any value
# print(sess.run(c)) # InvalidArgumentError because a doesnt have any value

# feed [1, 2, 3] to placeholder a via the dict {a: [1, 2, 3]}
# fetch value of c
Expand All @@ -35,4 +35,4 @@
replace_dict = {a: 15}

# Run the session, passing in 'replace_dict' as the value to 'feed_dict'
print(sess.run(b, feed_dict=replace_dict)) # >> 45
print(sess.run(b, feed_dict=replace_dict)) # >> 45
3 changes: 2 additions & 1 deletion examples/02_simple_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
with tf.Session() as sess:
writer = tf.summary.FileWriter('./graphs', sess.graph)
print(sess.run(x))
writer.close() # close the writer when you’re done using it
writer.close() # close the writer when youre done using it


a = tf.constant([2, 2], name='a')
Expand All @@ -27,6 +27,7 @@
# >> [[0 2]
# [4 6]]

shape = [2, 2]
tf.zeros(shape, dtype=tf.float32, name=None)
#creates a tensor of shape and all elements will be zeros (when ran in session)

Expand Down
8 changes: 4 additions & 4 deletions examples/03_linear_regression_sol.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
Y_predicted = X * w + b

# Step 5: use the square error as the loss function
loss = tf.square(Y - Y_predicted, name='loss')
# loss = utils.huber_loss(Y, Y_predicted)
#loss = tf.square(Y - Y_predicted, name='loss')
loss = utils.huber_loss(Y, Y_predicted)

# Step 6: using gradient descent with learning rate of 0.01 to minimize loss
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001).minimize(loss)
Expand All @@ -48,7 +48,7 @@
writer = tf.summary.FileWriter('./graphs/linear_reg', sess.graph)

# Step 8: train the model
for i in range(50): # train the model 100 epochs
for i in range(100): # train the model 100 epochs
total_loss = 0
for x, y in data:
# Session runs train_op and fetch values of loss
Expand All @@ -67,4 +67,4 @@
plt.plot(X, Y, 'bo', label='Real data')
plt.plot(X, X * w + b, 'r', label='Predicted data')
plt.legend()
plt.show()
plt.show()
4 changes: 2 additions & 2 deletions examples/03_logistic_regression_mnist_sol.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Step 1: Read in data
# using TF Learn's built in function to load MNIST data to the folder data/mnist
mnist = input_data.read_data_sets('/data/mnist', one_hot=True)
mnist = input_data.read_data_sets('./data/mnist', one_hot=True)

# Step 2: create placeholders for features and labels
# each image in the MNIST data is of shape 28*28 = 784
Expand Down Expand Up @@ -84,7 +84,7 @@
for i in range(n_batches):
X_batch, Y_batch = mnist.test.next_batch(batch_size)
accuracy_batch = sess.run([accuracy], feed_dict={X: X_batch, Y:Y_batch})
total_correct_preds += accuracy_batch
total_correct_preds += accuracy_batch[0]

print('Accuracy {0}'.format(total_correct_preds/mnist.test.num_examples))

Expand Down
27 changes: 27 additions & 0 deletions setup/setup_instruction.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ $ virtualenv venv --distribute --system-site-packages
```
### For Ubuntu

Step 1: set up pip and virtual environment
```bash
$ sudo apt-get install python-pip
$ sudo pip install virtualenv
```

Step 2: set up a project directory. You will do all work for this class in this directory
```bash
$ mkdir [my project]
```

Step 3: set up virtual environment for the project directory.
```bash
$ cd [my project]
$ virtualenv venv
```
These commands create a venv subdirectory in your project where everything is installed.

Step 4: to activate the virtual environment
```bash
$ source venv/bin/activate
```

Step 5: install tensorflow and other dependencies
```bash
$ pip install -r setup/requirements
```

### For Windows

Expand Down