In [1]:
# !pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.0-cp35-cp35m-win_amd64.whl

In [2]:
# test tf
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))


b'Hello, TensorFlow!'

In [7]:
from sklearn import metrics, cross_validation
import tensorflow as tf
from tensorflow.contrib import learn

import pandas as pd
import numpy as np
from sklearn import preprocessing


import src.misc.paths as path
import src.vector_gen.generateTimeInformationVector as gtiv
import src.vector_gen.generate_VectorY as gvy

%matplotlib inline

training_files = "../../dataset/training/"
trajectories_file = "trajectories(table 5)_training.csv"
trajectories_df = pd.read_csv(training_files+trajectories_file)

prepare data


In [12]:
x_df = gtiv.generate_timeInformation_df(trajectories_df)
y_df = gvy.generate_VectorY_df(trajectories_df)


1092

In [9]:
x


Out[9]:
weekday hour minute
2016-07-19 00:00:00 1 0 0
2016-07-19 02:00:00 1 2 0
2016-07-19 04:00:00 1 4 0
2016-07-19 06:00:00 1 6 0
2016-07-19 08:00:00 1 8 0
2016-07-19 10:00:00 1 10 0
2016-07-19 12:00:00 1 12 0
2016-07-19 14:00:00 1 14 0
2016-07-19 16:00:00 1 16 0
2016-07-19 18:00:00 1 18 0
2016-07-19 20:00:00 1 20 0
2016-07-19 22:00:00 1 22 0
2016-07-20 00:00:00 2 0 0
2016-07-20 02:00:00 2 2 0
2016-07-20 04:00:00 2 4 0
2016-07-20 06:00:00 2 6 0
2016-07-20 08:00:00 2 8 0
2016-07-20 10:00:00 2 10 0
2016-07-20 12:00:00 2 12 0
2016-07-20 14:00:00 2 14 0
2016-07-20 16:00:00 2 16 0
2016-07-20 18:00:00 2 18 0
2016-07-20 20:00:00 2 20 0
2016-07-20 22:00:00 2 22 0
2016-07-21 00:00:00 3 0 0
2016-07-21 02:00:00 3 2 0
2016-07-21 04:00:00 3 4 0
2016-07-21 06:00:00 3 6 0
2016-07-21 08:00:00 3 8 0
2016-07-21 10:00:00 3 10 0
... ... ... ...
2016-10-15 10:00:00 5 10 0
2016-10-15 12:00:00 5 12 0
2016-10-15 14:00:00 5 14 0
2016-10-15 16:00:00 5 16 0
2016-10-15 18:00:00 5 18 0
2016-10-15 20:00:00 5 20 0
2016-10-15 22:00:00 5 22 0
2016-10-16 00:00:00 6 0 0
2016-10-16 02:00:00 6 2 0
2016-10-16 04:00:00 6 4 0
2016-10-16 06:00:00 6 6 0
2016-10-16 08:00:00 6 8 0
2016-10-16 10:00:00 6 10 0
2016-10-16 12:00:00 6 12 0
2016-10-16 14:00:00 6 14 0
2016-10-16 16:00:00 6 16 0
2016-10-16 18:00:00 6 18 0
2016-10-16 20:00:00 6 20 0
2016-10-16 22:00:00 6 22 0
2016-10-17 00:00:00 0 0 0
2016-10-17 02:00:00 0 2 0
2016-10-17 04:00:00 0 4 0
2016-10-17 06:00:00 0 6 0
2016-10-17 08:00:00 0 8 0
2016-10-17 10:00:00 0 10 0
2016-10-17 12:00:00 0 12 0
2016-10-17 14:00:00 0 14 0
2016-10-17 16:00:00 0 16 0
2016-10-17 18:00:00 0 18 0
2016-10-17 20:00:00 0 20 0

1091 rows × 3 columns


In [10]:
y


Out[10]:
(0, A2) (0, A3) (0, B1) (0, B3) (0, C1) (0, C3) (1, A2) (1, A3) (1, B1) (1, B3) ... (4, B1) (4, B3) (4, C1) (4, C3) (5, A2) (5, A3) (5, B1) (5, B3) (5, C1) (5, C3)
2016-07-19 00:00:00 46.02 60.06 18.62 70.85 38.50 27.91 58.05 64.30 79.76 148.79 ... 176.70 39.41 214.87 16.20 77.74 45.09 9.92 93.72 160.63 8.17
2016-07-19 02:00:00 37.09 35.27 15.58 67.81 8.36 17.12 42.64 77.61 10.38 25.51 ... 11.06 31.36 13.87 11.76 39.43 46.12 12.01 98.49 12.14 7.78
2016-07-19 04:00:00 48.13 45.88 9.91 96.67 15.55 9.84 62.11 40.29 94.06 53.15 ... 66.98 48.19 30.07 26.15 58.08 70.58 87.83 48.22 67.51 33.00
2016-07-19 06:00:00 46.36 124.66 170.09 145.94 160.38 42.83 48.59 89.85 64.27 127.35 ... 73.54 82.63 92.15 236.12 58.97 155.49 69.42 110.50 180.11 60.60
2016-07-19 08:00:00 81.60 137.38 97.06 125.76 151.39 120.73 80.21 165.48 128.75 141.33 ... 104.33 127.38 164.52 104.67 69.66 129.28 87.74 117.83 132.77 139.70
2016-07-19 10:00:00 78.31 99.04 132.68 98.92 200.92 139.70 59.41 129.30 170.59 113.00 ... 74.90 84.36 195.16 93.07 47.98 86.68 80.95 96.54 182.46 88.35
2016-07-19 12:00:00 60.17 108.74 145.29 144.87 142.74 91.15 49.53 95.43 71.36 136.36 ... 140.65 119.37 172.16 180.09 61.13 102.92 99.61 176.65 117.03 140.79
2016-07-19 14:00:00 65.11 96.92 179.98 159.46 147.60 174.84 74.71 101.41 160.78 129.48 ... 163.81 129.47 257.20 185.51 58.74 112.32 90.01 120.76 137.86 125.78
2016-07-19 16:00:00 59.64 126.61 78.76 116.07 144.70 183.07 51.97 95.45 105.64 152.50 ... 66.65 103.67 192.50 172.78 65.67 102.47 82.13 109.30 141.04 203.77
2016-07-19 18:00:00 85.11 99.14 77.42 108.30 202.21 134.43 50.57 109.12 382.03 91.94 ... 62.14 115.99 83.93 219.38 89.64 128.92 115.00 209.49 83.93 90.56
2016-07-19 20:00:00 87.94 113.02 128.65 112.25 164.91 72.64 44.09 105.55 59.01 84.75 ... 155.63 133.02 114.64 65.92 51.18 108.17 129.93 96.96 74.71 185.62
2016-07-19 22:00:00 46.09 141.25 35.65 149.31 83.33 51.67 91.85 87.91 37.17 100.55 ... 32.59 61.42 28.59 285.82 67.96 85.08 23.50 121.11 35.92 21.77
2016-07-20 00:00:00 46.02 81.05 18.62 50.16 38.50 27.91 37.89 62.65 16.13 45.35 ... 20.83 39.41 135.02 16.20 40.75 107.08 9.92 33.25 18.98 8.17
2016-07-20 02:00:00 49.12 35.27 15.58 28.74 8.36 17.12 18.68 82.09 10.38 127.48 ... 11.06 104.71 13.87 11.76 100.71 46.12 12.01 148.14 12.14 7.78
2016-07-20 04:00:00 105.65 144.06 9.91 113.72 15.55 9.84 64.32 77.24 30.23 129.63 ... 22.54 48.19 30.07 26.15 46.20 151.55 36.27 48.22 67.51 125.32
2016-07-20 06:00:00 44.10 97.48 122.68 112.36 74.69 42.83 59.87 102.50 67.35 386.44 ... 98.20 133.20 92.15 424.79 73.68 128.13 94.11 137.98 130.56 175.09
2016-07-20 08:00:00 61.01 140.36 212.31 182.66 237.40 155.16 332.16 192.68 81.16 127.68 ... 115.11 142.06 199.87 104.67 23.30 250.81 155.41 170.11 171.96 102.43
2016-07-20 10:00:00 341.79 175.94 107.35 103.82 228.74 221.42 70.14 118.92 91.98 146.52 ... 74.90 157.70 117.66 202.93 60.48 107.66 98.20 80.52 125.28 111.24
2016-07-20 12:00:00 53.99 105.16 76.36 111.79 187.53 91.15 49.55 109.57 91.31 47.27 ... 89.11 65.45 147.59 123.63 73.50 99.35 231.91 127.10 154.89 164.01
2016-07-20 14:00:00 66.64 115.73 155.33 95.36 147.60 203.20 57.33 112.98 159.89 110.72 ... 90.47 134.65 166.11 203.75 70.33 116.61 71.68 174.75 215.74 125.78
2016-07-20 16:00:00 67.11 87.68 144.83 130.69 105.20 159.47 82.79 126.26 80.05 98.28 ... 66.65 131.36 125.53 148.84 75.48 123.79 82.13 134.24 175.44 214.36
2016-07-20 18:00:00 67.89 114.30 77.42 101.55 213.84 200.78 85.11 102.69 69.72 113.77 ... 62.14 90.80 257.77 131.43 52.10 137.11 52.30 103.43 263.10 234.90
2016-07-20 20:00:00 57.61 116.09 115.93 91.33 205.59 72.64 52.58 113.43 59.01 156.44 ... 61.55 86.44 205.68 65.92 68.68 110.21 46.81 111.47 162.60 158.17
2016-07-20 22:00:00 55.45 108.71 121.78 91.52 150.18 185.89 44.94 88.03 37.17 62.19 ... 32.59 61.42 167.24 34.71 56.67 80.57 23.50 112.89 35.92 21.77
2016-07-21 00:00:00 39.21 82.98 18.62 85.00 38.50 27.91 36.43 95.15 16.13 45.35 ... 20.83 65.78 21.36 16.20 80.25 45.09 9.92 22.18 18.98 8.17
2016-07-21 02:00:00 45.19 35.27 15.58 28.74 8.36 17.12 28.59 35.20 10.38 25.51 ... 11.06 31.36 13.87 11.76 83.48 46.12 12.01 29.13 12.14 7.78
2016-07-21 04:00:00 51.53 90.69 9.91 23.75 15.55 9.84 49.89 40.29 93.61 393.05 ... 22.54 48.19 30.07 26.15 56.69 133.45 36.27 48.22 67.51 33.00
2016-07-21 06:00:00 63.18 86.80 56.34 166.81 218.35 42.83 87.03 94.82 64.27 136.67 ... 73.54 113.78 92.15 72.12 114.72 189.61 99.63 146.58 133.55 60.60
2016-07-21 08:00:00 116.07 160.08 151.02 107.11 125.38 64.31 125.10 151.10 108.87 111.23 ... 125.44 119.13 180.06 104.67 88.66 132.49 162.56 108.62 168.40 108.18
2016-07-21 10:00:00 68.50 130.22 151.15 103.82 131.04 100.98 64.06 115.15 91.98 107.04 ... 70.34 108.52 175.72 207.92 58.84 79.98 89.66 168.37 147.73 88.35
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2016-10-15 12:00:00 55.49 108.68 148.88 90.00 175.20 91.15 75.10 102.03 194.71 111.61 ... 131.88 123.81 311.30 211.62 76.85 107.19 322.43 94.48 345.66 210.76
2016-10-15 14:00:00 70.85 101.44 369.30 147.15 480.54 131.23 68.73 129.67 132.41 112.88 ... 99.66 72.51 226.76 200.01 64.57 105.97 166.30 131.37 220.01 195.49
2016-10-15 16:00:00 62.82 186.11 131.17 120.68 183.74 173.84 55.51 136.59 187.96 156.38 ... 118.43 143.56 288.68 201.31 56.20 131.52 208.65 116.47 156.18 176.67
2016-10-15 18:00:00 69.84 140.16 117.03 92.53 208.13 95.01 61.47 107.73 113.36 39.24 ... 62.14 104.38 174.08 79.10 54.73 116.60 121.98 76.71 83.93 187.67
2016-10-15 20:00:00 49.56 113.54 131.56 81.32 90.82 557.39 71.34 85.96 92.39 73.55 ... 61.55 75.68 160.54 127.78 61.11 85.04 152.00 81.70 181.06 57.90
2016-10-15 22:00:00 56.07 98.05 150.00 81.24 208.41 51.67 32.25 82.48 134.46 100.07 ... 164.11 137.85 28.59 127.32 59.24 91.96 88.84 94.80 142.51 21.77
2016-10-16 00:00:00 59.43 60.06 18.62 71.69 38.50 176.72 45.70 300.65 93.32 45.35 ... 20.83 53.37 21.36 16.20 27.07 45.09 9.92 22.18 18.98 8.17
2016-10-16 02:00:00 91.74 35.27 15.58 12.09 8.36 17.12 36.26 35.20 10.38 25.51 ... 11.06 206.38 13.87 11.76 54.07 126.42 12.01 29.13 12.14 7.78
2016-10-16 04:00:00 45.65 28.72 9.91 23.75 15.55 9.84 42.17 40.29 30.23 35.97 ... 22.54 86.44 114.24 26.15 44.47 94.31 36.27 48.22 285.05 33.00
2016-10-16 06:00:00 44.35 107.90 56.34 62.56 74.69 42.83 43.37 97.01 64.27 90.34 ... 112.56 94.86 137.52 72.12 49.07 101.45 116.25 105.92 186.40 189.78
2016-10-16 08:00:00 65.10 114.11 112.75 93.91 166.49 64.31 78.61 135.07 102.82 98.29 ... 121.36 80.88 177.79 141.18 66.83 227.94 97.21 94.94 165.23 181.15
2016-10-16 10:00:00 72.15 171.94 103.33 54.65 210.89 124.70 70.30 132.77 124.10 79.78 ... 149.32 59.31 144.38 103.01 55.31 95.59 80.95 126.53 440.99 227.12
2016-10-16 12:00:00 64.06 93.59 134.29 100.55 266.24 152.97 54.81 95.45 143.35 102.87 ... 112.56 99.43 195.02 230.93 79.16 183.45 132.12 111.54 201.60 201.56
2016-10-16 14:00:00 52.68 175.09 149.55 103.92 253.72 190.71 60.43 118.46 91.03 128.19 ... 128.09 135.54 234.90 209.33 66.86 85.67 120.06 106.91 210.66 286.61
2016-10-16 16:00:00 72.75 168.21 133.51 103.95 264.98 235.16 71.52 164.68 172.85 97.74 ... 153.68 117.52 226.31 215.28 93.63 93.54 183.33 110.75 180.95 224.67
2016-10-16 18:00:00 63.15 135.56 117.24 110.04 241.96 141.09 70.38 128.98 69.72 104.61 ... 160.60 68.83 269.18 156.06 68.37 94.52 52.30 104.63 202.09 190.96
2016-10-16 20:00:00 64.10 123.63 120.15 87.52 164.39 153.81 54.89 104.32 112.66 90.29 ... 106.95 81.92 224.93 65.92 357.05 105.93 110.85 78.72 74.71 57.90
2016-10-16 22:00:00 64.01 103.64 35.65 106.78 183.47 51.67 58.27 105.03 37.17 62.19 ... 80.86 61.42 28.59 34.71 52.26 84.51 23.50 90.29 35.92 21.77
2016-10-17 00:00:00 59.61 89.41 95.71 70.85 38.50 27.91 40.03 77.48 16.13 125.27 ... 106.77 88.43 21.36 16.20 27.07 45.09 9.92 22.18 18.98 8.17
2016-10-17 02:00:00 37.09 35.27 15.58 28.74 8.36 17.12 51.25 35.20 10.38 25.51 ... 11.06 93.78 13.87 11.76 47.24 46.12 12.01 29.13 12.14 7.78
2016-10-17 04:00:00 56.49 91.66 9.91 73.25 15.55 9.84 69.42 126.47 30.23 35.97 ... 22.54 48.19 30.07 26.15 45.24 72.77 135.14 113.93 67.51 33.00
2016-10-17 06:00:00 43.74 68.25 56.34 83.62 196.30 42.83 48.09 140.63 75.72 43.62 ... 73.54 69.52 224.46 72.12 72.16 171.10 136.97 110.83 168.88 60.60
2016-10-17 08:00:00 133.58 306.58 108.63 147.11 165.10 64.31 108.33 296.26 115.41 118.52 ... 108.23 149.29 151.34 104.67 53.21 128.11 122.42 120.32 265.43 218.18
2016-10-17 10:00:00 64.87 118.49 161.91 129.52 142.21 220.20 76.01 132.14 88.98 50.23 ... 102.55 102.44 153.59 93.07 44.09 98.61 100.05 109.67 172.90 88.35
2016-10-17 12:00:00 65.24 99.45 131.03 94.10 167.98 104.38 45.44 104.89 104.69 77.63 ... 111.03 84.63 218.76 169.18 64.32 93.51 134.56 81.00 165.84 149.21
2016-10-17 14:00:00 52.28 84.48 99.41 98.19 191.14 131.23 70.19 100.53 147.23 104.86 ... 138.69 82.67 134.58 124.07 71.70 131.03 76.92 126.84 483.07 125.78
2016-10-17 16:00:00 53.86 109.92 134.99 115.47 180.28 171.02 69.77 111.73 136.45 100.27 ... 130.78 118.25 170.14 122.02 53.69 125.55 177.36 102.55 132.85 107.45
2016-10-17 18:00:00 65.40 158.01 77.42 102.74 267.11 173.74 48.66 115.05 98.47 83.02 ... 62.14 91.64 83.93 79.10 65.93 86.11 99.04 96.84 188.23 187.43
2016-10-17 20:00:00 52.66 101.30 62.67 99.77 90.82 209.32 72.69 137.58 172.53 84.75 ... 61.55 61.96 121.61 159.44 39.55 100.03 46.81 73.88 74.71 57.90
2016-10-17 22:00:00 69.05 80.10 35.65 68.51 83.33 51.67 50.18 71.97 136.78 115.60 ... 97.54 131.68 159.78 34.71 42.27 113.94 23.50 39.47 35.92 21.77

1092 rows × 36 columns

Feature Selection


In [ ]:
feature_cols = ['route', 'hour', 'minute', 'dayofweek']
predict_cols = ['avg_travel_time']
#feature_cols = ['hour', 'minute', 'dayofweek']

tmp_all_cols = feature_cols.copy()
tmp_all_cols.extend(predict_cols)

df.reset_index()[tmp_all_cols].head(8)

split train and test


In [16]:
#from sklearn.model_selection import train_test_split

# not working!?!?!
import src.misc.split_train_valid as split
#training, validation, testing = split.split_dataset(x_df, 0.8, 0)

#x_train, x_test, y_train, y_test = train_test_split(df[feature_cols], df['avg_travel_time'], test_size=0.2, random_state=42)

# k-fold cross validation
# 13 weeks

# by hand?
# 91 days -> 13 weeks 
# 8 weeks to train
num_weeks_train = (7*24*3*6) * 8

x_train = x_df[:num_weeks_train]
x_test = x_df[num_weeks_train:]
y_train = y_df[:num_weeks_train]
y_test = y_df[num_weeks_train:]

tensorflow


In [17]:
# Model parameters
W = tf.Variable([.3], dtype=tf.float32)
b = tf.Variable([-.3], dtype=tf.float32)
# Model input and output
x = tf.placeholder(tf.float32)
linear_model = W * x + b
y = tf.placeholder(tf.float32)

# loss
loss = tf.reduce_sum(tf.square(linear_model - y))

# optimizer
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)

# training data
#x_train = [1,2,3,4]
#y_train = [0,-1,-2,-3]

# training loop
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init) # reset values to wrong
for i in range(1000):
  sess.run(train, {x:x_train, y:y_train})

# evaluate training accuracy
curr_W, curr_b, curr_loss = sess.run([W, b, loss], {x:x_train, y:y_train})
print("W: %s b: %s loss: %s"%(curr_W, curr_b, curr_loss))


---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
C:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1138     try:
-> 1139       return fn(*args)
   1140     except errors.OpError as e:

C:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1120                                  feed_dict, fetch_list, target_list,
-> 1121                                  status, run_metadata)
   1122 

C:\Anaconda3\lib\contextlib.py in __exit__(self, type, value, traceback)
     65             try:
---> 66                 next(self.gen)
     67             except StopIteration:

C:\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status()
    465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466           pywrap_tensorflow.TF_GetCode(status))
    467   finally:

InvalidArgumentError: Incompatible shapes: [1091,3] vs. [1092,36]
	 [[Node: gradients_1/sub_1_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"](gradients_1/sub_1_grad/Shape, gradients_1/sub_1_grad/Shape_1)]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-17-be1e98d5504b> in <module>()
     23 sess.run(init) # reset values to wrong
     24 for i in range(1000):
---> 25   sess.run(train, {x:x_train, y:y_train})
     26 
     27 # evaluate training accuracy

C:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    787     try:
    788       result = self._run(None, fetches, feed_dict, options_ptr,
--> 789                          run_metadata_ptr)
    790       if run_metadata:
    791         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

C:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    995     if final_fetches or final_targets:
    996       results = self._do_run(handle, final_targets, final_fetches,
--> 997                              feed_dict_string, options, run_metadata)
    998     else:
    999       results = []

C:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1130     if handle is None:
   1131       return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1132                            target_list, options, run_metadata)
   1133     else:
   1134       return self._do_call(_prun_fn, self._session, handle, feed_dict,

C:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1150         except KeyError:
   1151           pass
-> 1152       raise type(e)(node_def, op, message)
   1153 
   1154   def _extend_graph(self):

InvalidArgumentError: Incompatible shapes: [1091,3] vs. [1092,36]
	 [[Node: gradients_1/sub_1_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"](gradients_1/sub_1_grad/Shape, gradients_1/sub_1_grad/Shape_1)]]

Caused by op 'gradients_1/sub_1_grad/BroadcastGradientArgs', defined at:
  File "C:\Anaconda3\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Anaconda3\lib\site-packages\ipykernel\__main__.py", line 3, in <module>
    app.launch_new_instance()
  File "C:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 653, in launch_instance
    app.start()
  File "C:\Anaconda3\lib\site-packages\ipykernel\kernelapp.py", line 474, in start
    ioloop.IOLoop.instance().start()
  File "C:\Anaconda3\lib\site-packages\zmq\eventloop\ioloop.py", line 162, in start
    super(ZMQIOLoop, self).start()
  File "C:\Anaconda3\lib\site-packages\tornado\ioloop.py", line 887, in start
    handler_func(fd_obj, events)
  File "C:\Anaconda3\lib\site-packages\tornado\stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
    self._handle_recv()
  File "C:\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
    self._run_callback(callback, msg)
  File "C:\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
    callback(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\tornado\stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 276, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "C:\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 228, in dispatch_shell
    handler(stream, idents, msg)
  File "C:\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 390, in execute_request
    user_expressions, allow_stdin)
  File "C:\Anaconda3\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "C:\Anaconda3\lib\site-packages\ipykernel\zmqshell.py", line 501, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2717, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2821, in run_ast_nodes
    if self.run_code(code, result):
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-17-be1e98d5504b>", line 14, in <module>
    train = optimizer.minimize(loss)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 315, in minimize
    grad_loss=grad_loss)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 386, in compute_gradients
    colocate_gradients_with_ops=colocate_gradients_with_ops)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py", line 540, in gradients
    grad_scope, op, func_call, lambda: grad_fn(op, *out_grads))
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py", line 346, in _MaybeCompile
    return grad_fn()  # Exit early
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py", line 540, in <lambda>
    grad_scope, op, func_call, lambda: grad_fn(op, *out_grads))
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\math_grad.py", line 650, in _SubGrad
    rx, ry = gen_array_ops._broadcast_gradient_args(sx, sy)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 395, in _broadcast_gradient_args
    name=name)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in __init__
    self._traceback = _extract_stack()

...which was originally created as op 'sub_1', defined at:
  File "C:\Anaconda3\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
[elided 18 identical lines from previous traceback]
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-17-be1e98d5504b>", line 10, in <module>
    loss = tf.reduce_sum(tf.square(linear_model - y))
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 838, in binary_op_wrapper
    return func(x, y, name=name)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 2501, in _sub
    result = _op_def_lib.apply_op("Sub", x=x, y=y, name=name)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Incompatible shapes: [1091,3] vs. [1092,36]
	 [[Node: gradients_1/sub_1_grad/BroadcastGradientArgs = BroadcastGradientArgs[T=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"](gradients_1/sub_1_grad/Shape, gradients_1/sub_1_grad/Shape_1)]]