-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
DNN random seed (NCF, xDeepFM, W&D) #785
Conversation
…. Update wide-deep
Check out this pull request on ReviewNB: https://app.reviewnb.com/microsoft/recommenders/pull/785 Visit www.reviewnb.com to know how we simplify your Jupyter Notebook workflows. |
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.
this is really good @loomlike, see my comments
reco_utils/common/tf_utils.py
Outdated
import tensorflow as tf | ||
from tensorflow.python.estimator.inputs.queues import feeding_functions | ||
from tensorflow.python.estimator.inputs.numpy_io import ( | ||
_get_unique_target_key, |
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.
this hurts a little bit lol, but I guess it's not our fault. I guess there are no public functions that we can use right?
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.
ah... yeah. Not sure why they did not expose the seed variable to numpy input function.
If we really don't want to do this, alternative way is to shuffle by ourselves like:
def numpy_input_fn(x, ...):
...
if shuffle==True and seed is not None:
# set random seed and shuffle x
....
# then call tf's numpy_input_fn with the shuffled x
tf.estimator.inputs.numpy_input_fn(x)
I actually like this solution. Much cleaner.
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.
Ah... the thing is, w/ this, we cannot shuffle for every epoch... hmmm
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.
I think ‘tf.set_random_seed’ will work for this case. Let me try and will update codes if works.
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.
Refactored to use tf.data.dataset
(newer API) within our pandas_input_fn
and now much cleaner.
@loomlike, hope you don't mind me commiting directly to your branch, I think it was faster to just remove the line than to tell you to do it :-)
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.
LGTM, probably we want to merge this before the merge to master
DNN random seed (NCF, xDeepFM, W&D)
Description
Refactor NCF (dataset and model) and W&D (input_fns) to accept random seed.
Update tests accordingly
Related Issues
#736
Checklist: