title: TensorFlow: cast a float64 tensor to float32
body: <p>I am trying to use: <code>train = optimizer.minimize(loss)</code> but the standard optimizers do not work with <code>tf.float64</code>. Therefore I want to truncate my <code>loss</code> from <code>tf.float64</code> to only <code>tf.float32</code>.  </p>
  
  <pre><code>Traceback (most recent call last):
    File "q4.py", line 85, in &lt;module&gt;
      train = optimizer.minimize(loss)
    File "/Library/Python/2.7/site-packages/tensorflow/python/training/optimizer.py", line 190, in minimize
      colocate_gradients_with_ops=colocate_gradients_with_ops)
    File "/Library/Python/2.7/site-packages/tensorflow/python/training/optimizer.py", line 229, in compute_gradients
      self._assert_valid_dtypes([loss])
    File "/Library/Python/2.7/site-packages/tensorflow/python/training/optimizer.py", line 354, in _assert_valid_dtypes
      dtype, t.name, [v for v in valid_dtypes]))
  ValueError: Invalid type tf.float64 for Add_1:0, expected: [tf.float32].
  </code></pre>