Skip to content

Commit

Permalink
Document that hub.KerasLayer does not implement precision policy.
Browse files Browse the repository at this point in the history
This answers issue tensorflow#466

PiperOrigin-RevId: 288445293
  • Loading branch information
TensorFlow Hub Authors authored and arnoegw committed Jan 7, 2020
1 parent 945303a commit 27357e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/common_issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ session.run(init_op)
```python
result = session.run(embedded_text, feed_dict={text_input: ["Hello world"]})
```

## Cannot change a model's dype (e.g., float32 to bfloat16)

TensorFlow's SavedModels (shared on TF Hub or otherwise) contain
operations that work on fixed data types (often, float32 for the weights
and intermediate activations of neural networks). These cannot be
changed after the fact when lodaing the SavedModel (but model publishers
can choose to publish different models with different data types).
4 changes: 4 additions & 0 deletions tensorflow_hub/keras_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class KerasLayer(tf.keras.layers.Layer):
explicitly from Keras objects instead of relying on graph collections.
This layer class does not support graph collections.
Note: The data types used by a saved model have been fixed at saving time.
Using tf.keras.mixed_precision etc. has no effect on the saved model
that gets loaded by a hub.KerasLayer.
Attributes:
handle: A callable object (subject to the conventions above), or a
Python string to load a saved model via hub.load().
Expand Down

0 comments on commit 27357e9

Please sign in to comment.