TensorFlow v1 to v2 migration for NCF models#668
TensorFlow v1 to v2 migration for NCF models#668qtuantruong merged 1 commit intoPreferredAI:masterfrom
Conversation
|
I ran
The environment setup was quite troublesome on my side. I had some version conflicts between Shall we split the
Also, what do you think about updating |
|
@hieuddo could you try setting up a new env with the following |
|
Yeah, it worked. I guess it was because I installed one by one, and
|
Looks like we've already indicated in the example that there are two options of backend. I'm open to updating the example to run both if you think it's necessary. |
|
It's not really necessary. I just thought it might be helpful to see the comparisons between 2 backends in one run. Feel free to merge! |
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 tfandtf.disable_v2_behavior()import tensorflow as tf2. Session-based to Keras Model-based Approach
_build_graph_tfto_build_model_tfto reflect the Keras model approach3. Updated Backend Implementation
backend_tf.py4. Updated Training Loop
GradientTape5. Updated Pretrained Model Handling
File-specific Changes
backend_tf.py
GMFLayerandMLPLayerclasses that extendtf.keras.layers.Layerrecom_ncf_base.py
_fit_tfto use eager execution withGradientTape_score_tfmethod that uses the Keras modelrecom_gmf.py, recom_mlp.py, recom_neumf.py
recom_neumf.py