fix dtype handling in 2 optimizers and 1 layer
diff --git a/keras/backend/tensorflow_backend.py b/keras/backend/tensorflow_backend.py
index 8ebd473bf88..4ea7823abf2 100644
--- a/keras/backend/tensorflow_backend.py
+++ b/keras/backend/tensorflow_backend.py
@@ -549,7 +549,7 @@ def dtype(x):
         'float32_ref'
     ```
     """
-    return x.dtype.name
+    return x.dtype.base_dtype.name
 
 
 def eval(x):
diff --git a/keras/layers/embeddings.py b/keras/layers/embeddings.py
index 157d3f01edf..557c7d52551 100644
--- a/keras/layers/embeddings.py
+++ b/keras/layers/embeddings.py
@@ -75,7 +75,6 @@ def __init__(self, input_dim, output_dim,
                  mask_zero=False,
                  input_length=None,
                  **kwargs):
-        kwargs['dtype'] = 'int32'
         if 'input_shape' not in kwargs:
             if input_length:
                 kwargs['input_shape'] = (input_length,)
@@ -98,7 +97,8 @@ def build(self, input_shape):
             initializer=self.embeddings_initializer,
             name='embeddings',
             regularizer=self.embeddings_regularizer,
-            constraint=self.embeddings_constraint)
+            constraint=self.embeddings_constraint,
+            dtype=self.dtype)
         self.built = True
 
     def compute_mask(self, inputs, mask=None):
diff --git a/keras/optimizers.py b/keras/optimizers.py
index bde1e422af1..ec9484adb40 100644
--- a/keras/optimizers.py
+++ b/keras/optimizers.py
@@ -195,8 +195,7 @@ def __init__(self, lr=0.001, rho=0.9, epsilon=1e-8, decay=0.,
 
     def get_updates(self, params, constraints, loss):
         grads = self.get_gradients(loss, params)
-        shapes = [K.get_variable_shape(p) for p in params]
-        accumulators = [K.zeros(shape) for shape in shapes]
+        accumulators = [K.zeros(K.get_variable_shape(p), dtype=K.dtype(p)) for p in params]
         self.weights = accumulators
         self.updates = []
 
@@ -389,9 +388,8 @@ def get_updates(self, params, constraints, loss):
         lr_t = lr * (K.sqrt(1. - K.pow(self.beta_2, t)) /
                      (1. - K.pow(self.beta_1, t)))
 
-        shapes = [K.get_variable_shape(p) for p in params]
-        ms = [K.zeros(shape) for shape in shapes]
-        vs = [K.zeros(shape) for shape in shapes]
+        ms = [K.zeros(K.get_variable_shape(p), dtype=K.dtype(p)) for p in params]
+        vs = [K.zeros(K.get_variable_shape(p), dtype=K.dtype(p)) for p in params]
         self.weights = [self.iterations] + ms + vs
 
         for p, g, m, v in zip(params, grads, ms, vs):

Update `Adam` and `RMSprop` so dtype of momentum variables matches dtype of corresponding parameter. Shouldn't affect most people unless you're using a mix of dtypes. Would be nice if `K.zeros_like` used the parameter's dtype but that might break a lot of other things. May be worth updating the other optimizers but those are the two I use the most.

Update `Embedding` layer to have a `output_dtype` parameter that is passed to `add_weight`. Useful if you need mixed precision or if you have integer embeddings (`trainable=False`).

Cheers