TensorFlow v1 to v2 migration for NCF models #668
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TensorFlow v1 to v2 Migration for NCF models
This outlines the changes made to migrate the Neural Collaborative Filtering (NCF) models from TensorFlow v1 to TensorFlow v2.
Key Changes
1. Removed TensorFlow v1 Compatibility Mode
import tensorflow.compat.v1 as tf
andtf.disable_v2_behavior()
import tensorflow as tf
2. Session-based to Keras Model-based Approach
_build_graph_tf
to_build_model_tf
to reflect the Keras model approach3. Updated Backend Implementation
backend_tf.py
4. Updated Training Loop
GradientTape
5. Updated Pretrained Model Handling
File-specific Changes
backend_tf.py
GMFLayer
andMLPLayer
classes that extendtf.keras.layers.Layer
recom_ncf_base.py
_fit_tf
to use eager execution withGradientTape
_score_tf
method that uses the Keras modelrecom_gmf.py, recom_mlp.py, recom_neumf.py
recom_neumf.py