got TypeError when running linear regression with tensorflow. ' Op has type float64 that does not match type float32 of argument'
<p>I'm pretty new to tensorflow. I did a linear regression with tensorflow. 
when I ran the codes below, I got typeError like this:</p>

<p>TypeError: Input 'y' of 'Mul' Op has type float64 that does not match type float32 of argument 'x'.</p>

<p>Spent hours but could not figure out why. 
where did it go wrong?  help is very much appreciated. thanks a lot. </p>

<pre><code>import tensorflow as tf
import numpy as np

training_epoch = 1000
display_epoch=50
learning_rate = 0.01
train_X = np.asarray([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167,
                         7.042,10.791,5.313,7.997,5.654,9.27,3.1])
train_Y = np.asarray([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221,
                         2.827,3.465,1.65,2.904,2.42,2.94,1.3])
n_samples = train_X.shape[0]
X = tf.placeholder('float')
Y= tf.placeholder ('float')
w = tf.Variable(np.random.randn(2))
pred = tf.add(tf.mul(X,w[0]), w[1])

loss = tf.reduce_sum(tf.pow(pred-Y, 2))/(2*n_samples)
init = tf.initialize_all_variables()
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(loss)

with tf.Session() as session:
    session.run(init)
    for epoch in range(training_epoch):
        for x, y in zip(train_X, train_Y):
            session.run(optimizer, feed_dict={X:x, Y:y})
        if (epoch+1) % display_epoch == 0:
            weight = session.run(w)
            bias = session.run(b)
            cost = session.run(loss, feed_dict={X:train_X, Y:train_Y})
            print('epoch: {0:.2f}, weight: {1:.9f}. bias: {2:.9f}, cost: {3:.9f}'.format(epoch+1,weight[0], weight[1], cost))
    print('optimization complete')
</code></pre>