diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-06-18 17:05:03 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-06-18 17:14:10 -0700 |
commit | c70b8e73af3423d1e50dfade2c92e3d553a534d9 (patch) | |
tree | 817555c6bfdd4b3e684821a876319610305d8ac1 /tensorflow/python/keras/backend.py | |
parent | ca24a3e823884e6a1929ca5afc09b77677dd67c3 (diff) |
The pretrained text embedding models in tf.hub expect a string input. If I pass dtype as tf.string in tf.keras.layers.InputLayer, it fails in a numpy array conversion as numpy doesn't recognize tf string type. I have added a check for that and if the input is a string, then the dtype passed to np.asarray is object.
PiperOrigin-RevId: 201085946
Diffstat (limited to 'tensorflow/python/keras/backend.py')
-rw-r--r-- | tensorflow/python/keras/backend.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tensorflow/python/keras/backend.py b/tensorflow/python/keras/backend.py index 84821918bf..c55a756bcc 100644 --- a/tensorflow/python/keras/backend.py +++ b/tensorflow/python/keras/backend.py @@ -2880,7 +2880,10 @@ class Function(object): feed_arrays.append(tensor) # We need to do array conversion and type casting at this level, since # `callable_fn` only supports exact matches. - array_vals.append(np.asarray(value, dtype=tensor.dtype.base_dtype.name)) + tensor_type = dtypes_module.as_dtype(tensor.dtype) + array_vals.append(np.asarray(value, + dtype=tensor_type.as_numpy_dtype)) + if self.feed_dict: for key in sorted(self.feed_dict.keys()): array_vals.append( |