-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added wrapper for tensorflow 2.2.0 #6
base: master
Are you sure you want to change the base?
Conversation
First thank you so much on the pull request. I'm sorry it took me a long time to see it. For some reason GitHub didn't inform me. Now the application doesn't need two tensorflow wrapper. If you like to bump up the tensorflow version please firstly update the requirements file. See my other CR in the file. |
import tensorflow_hub | ||
|
||
|
||
class TensorFlowWrapper: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the original tensorflow_wrapper.py
# Import the Universal Sentence Encoder's TF Hub module | ||
embedding_layer = tensorflow_hub.Module(embedding_layer_hub_name) | ||
|
||
self._sts_input1 = tensorflow.compat.v1.placeholder(tensorflow.string, shape=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tf.disable_v2_behavior() if you'd like to use tf1 behavior.
I suggest moving to tensorflow v2 behavior. Replace compat.v1.placeholder with their match in tf2 such as:
placeholder become Variable or keras.layers.Model.
See full guide here: https://www.tensorflow.org/guide/migrate
embedding_layer = tensorflow_hub.Module(embedding_layer_hub_name) | ||
|
||
self._sts_input1 = tensorflow.compat.v1.placeholder(tensorflow.string, shape=None) | ||
self._sts_input2 = tensorflow.compat.v1.placeholder(tensorflow.string, shape=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tf.disable_v2_behavior() if you'd like to use tf1 behavior or migrate to tensorflow v2.
See previous remark.
axis=1) | ||
clip_cosine_similarities = tensorflow.clip_by_value(cosine_similarities, -1.0, 1.0) | ||
self._sim_scores = 1.0 - tensorflow.math.acos(clip_cosine_similarities) | ||
init_op = tensorflow.group([tensorflow.compat.v1.global_variables_initializer(), tensorflow.compat.v1.tables_initializer()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tf.disable_v2_behavior() if you'd like to use tf1 behavior or migrate to tensorflow v2.
See previous remark.
init_op = tensorflow.group([tensorflow.compat.v1.global_variables_initializer(), tensorflow.compat.v1.tables_initializer()]) | ||
g.finalize() | ||
|
||
self._session = tensorflow.compat.v1.Session(graph=g) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tf.disable_v2_behavior() if you'd like to use tf1 behavior or migrate to tensorflow v2.
See previous remark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test file please
No description provided.