Skip to content
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

RippleNet using Wikidata and Movielens #1014

Open
wants to merge 82 commits into
base: staging
Choose a base branch
from
Open

Conversation

almudenasanz
Copy link
Collaborator

@almudenasanz almudenasanz commented Dec 17, 2019

Description

Notebook showcasing RippleNet https://github.com/hwwang55/RippleNet and related files
Uses Movielens dataset and Wikidata as the KG
Reproduces results of https://arxiv.org/abs/1803.03467 for Movielens 1M using Wikidata instead of Microsoft Satori as the KG

Need to update tests

Related Issues

Checklist:

  • I have followed the contribution guidelines and code style for this project.
  • I have added tests covering my contributions.
  • I have updated the documentation accordingly.

@miguelgfierro
Copy link
Collaborator

@almudenasanz, this is the error I got:

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1333     try:
-> 1334       return fn(*args)
   1335     except errors.OpError as e:

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1318       return self._call_tf_sessionrun(
-> 1319           options, feed_dict, fetch_list, target_list, run_metadata)
   1320 

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1406         self._session, options, feed_dict, fetch_list, target_list,
-> 1407         run_metadata)
   1408 

InvalidArgumentError: indices[6,12] = 22991 is not in [0, 22908)
	 [[{{node embedding_lookup_6}} = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_DOUBLE, _class=["loc:@Adam/Assign_1"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](entity_emb_matrix/read, _arg_memories_t_1_0_7, embedding_lookup/axis)]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-18-0bb7a5bc8c82> in <module>
      3                train_data=train_data[["user_index", "item", "rating"]].to_numpy(),
      4                ripple_set=ripple_set,
----> 5                show_loss=show_loss)
      6 
      7 print("Took {} seconds for training.".format(train_time.interval))

/data/home/hoaphumanoid/notebooks/repos/recommenders/reco_utils/recommender/ripplenet/model.py in fit(self, n_epoch, batch_size, train_data, ripple_set, show_loss)
    333                 _, loss = self._train(
    334                     self._get_feed_dict(
--> 335                         data=train_data, start=start, end=start + batch_size
    336                     )
    337                 )

/data/home/hoaphumanoid/notebooks/repos/recommenders/reco_utils/recommender/ripplenet/model.py in _train(self, feed_dict)
    273 
    274     def _train(self, feed_dict):
--> 275         return self.sess.run([self.optimizer, self.loss], feed_dict)
    276 
    277     def _return_scores(self, feed_dict):

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    927     try:
    928       result = self._run(None, fetches, feed_dict, options_ptr,
--> 929                          run_metadata_ptr)
    930       if run_metadata:
    931         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1150     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1151       results = self._do_run(handle, final_targets, final_fetches,
-> 1152                              feed_dict_tensor, options, run_metadata)
   1153     else:
   1154       results = []

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1326     if handle is None:
   1327       return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1328                            run_metadata)
   1329     else:
   1330       return self._do_call(_prun_fn, handle, feeds, fetches)

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1346           pass
   1347       message = error_interpolation.interpolate(message, self._graph)
-> 1348       raise type(e)(node_def, op, message)
   1349 
   1350   def _extend_graph(self):

InvalidArgumentError: indices[6,12] = 22991 is not in [0, 22908)
	 [[node embedding_lookup_6 (defined at ../../reco_utils/recommender/ripplenet/model.py:159)  = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_DOUBLE, _class=["loc:@Adam/Assign_1"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](entity_emb_matrix/read, _arg_memories_t_1_0_7, embedding_lookup/axis)]]

Caused by op 'embedding_lookup_6', defined at:
  File "/data/anaconda/envs/reco_base/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/data/anaconda/envs/reco_base/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelapp.py", line 563, in start
    self.io_loop.start()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 148, in start
    self.asyncio_loop.run_forever()
  File "/data/anaconda/envs/reco_base/lib/python3.6/asyncio/base_events.py", line 438, in run_forever
    self._run_once()
  File "/data/anaconda/envs/reco_base/lib/python3.6/asyncio/base_events.py", line 1451, in _run_once
    handle._run()
  File "/data/anaconda/envs/reco_base/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/ioloop.py", line 690, in <lambda>
    lambda f: self._run_callback(functools.partial(callback, future))
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 787, in inner
    self.run()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 748, in run
    yielded = self.gen.send(value)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 377, in dispatch_queue
    yield self.process_one()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 225, in wrapper
    runner = Runner(result, future, yielded)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 714, in __init__
    self.run()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 748, in run
    yielded = self.gen.send(value)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 361, in process_one
    yield gen.maybe_future(dispatch(*args))
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 541, in execute_request
    user_expressions, allow_stdin,
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 300, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 536, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2848, in run_cell
    raw_cell, store_history, silent, shell_futures)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2874, in _run_cell
    return runner(coro)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/async_helpers.py", line 68, in _pseudo_sync_runner
    coro.send(None)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3051, in run_cell_async
    interactivity=interactivity, compiler=compiler, result=result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3242, in run_ast_nodes
    if (await self.run_code(code, result,  async_=asy)):
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3319, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-17-b8b001ee6b13>", line 7, in <module>
    seed=seed)
  File "../../reco_utils/recommender/ripplenet/model.py", line 74, in __init__
    self._build_model()
  File "../../reco_utils/recommender/ripplenet/model.py", line 159, in _build_model
    tf.nn.embedding_lookup(self.entity_emb_matrix, self.memories_t[i])
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/embedding_ops.py", line 313, in embedding_lookup
    transform_fn=None)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/embedding_ops.py", line 133, in _embedding_lookup_and_transform
    result = _clip(array_ops.gather(params[0], ids, name=name),
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 2675, in gather
    return gen_array_ops.gather_v2(params, indices, axis, name=name)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3332, in gather_v2
    "GatherV2", params=params, indices=indices, axis=axis, name=name)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
    op_def=op_def)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1770, in __init__
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): indices[6,12] = 22991 is not in [0, 22908)
	 [[node embedding_lookup_6 (defined at ../../reco_utils/recommender/ripplenet/model.py:159)  = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_DOUBLE, _class=["loc:@Adam/Assign_1"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](entity_emb_matrix/read, _arg_memories_t_1_0_7, embedding_lookup/axis)]]

@almudenasanz
Copy link
Collaborator Author

almudenasanz commented Jan 21, 2020

@almudenasanz, this is the error I got:

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1333     try:
-> 1334       return fn(*args)
   1335     except errors.OpError as e:

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1318       return self._call_tf_sessionrun(
-> 1319           options, feed_dict, fetch_list, target_list, run_metadata)
   1320 

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1406         self._session, options, feed_dict, fetch_list, target_list,
-> 1407         run_metadata)
   1408 

InvalidArgumentError: indices[6,12] = 22991 is not in [0, 22908)
	 [[{{node embedding_lookup_6}} = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_DOUBLE, _class=["loc:@Adam/Assign_1"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](entity_emb_matrix/read, _arg_memories_t_1_0_7, embedding_lookup/axis)]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-18-0bb7a5bc8c82> in <module>
      3                train_data=train_data[["user_index", "item", "rating"]].to_numpy(),
      4                ripple_set=ripple_set,
----> 5                show_loss=show_loss)
      6 
      7 print("Took {} seconds for training.".format(train_time.interval))

/data/home/hoaphumanoid/notebooks/repos/recommenders/reco_utils/recommender/ripplenet/model.py in fit(self, n_epoch, batch_size, train_data, ripple_set, show_loss)
    333                 _, loss = self._train(
    334                     self._get_feed_dict(
--> 335                         data=train_data, start=start, end=start + batch_size
    336                     )
    337                 )

/data/home/hoaphumanoid/notebooks/repos/recommenders/reco_utils/recommender/ripplenet/model.py in _train(self, feed_dict)
    273 
    274     def _train(self, feed_dict):
--> 275         return self.sess.run([self.optimizer, self.loss], feed_dict)
    276 
    277     def _return_scores(self, feed_dict):

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    927     try:
    928       result = self._run(None, fetches, feed_dict, options_ptr,
--> 929                          run_metadata_ptr)
    930       if run_metadata:
    931         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1150     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1151       results = self._do_run(handle, final_targets, final_fetches,
-> 1152                              feed_dict_tensor, options, run_metadata)
   1153     else:
   1154       results = []

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1326     if handle is None:
   1327       return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1328                            run_metadata)
   1329     else:
   1330       return self._do_call(_prun_fn, handle, feeds, fetches)

/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1346           pass
   1347       message = error_interpolation.interpolate(message, self._graph)
-> 1348       raise type(e)(node_def, op, message)
   1349 
   1350   def _extend_graph(self):

InvalidArgumentError: indices[6,12] = 22991 is not in [0, 22908)
	 [[node embedding_lookup_6 (defined at ../../reco_utils/recommender/ripplenet/model.py:159)  = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_DOUBLE, _class=["loc:@Adam/Assign_1"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](entity_emb_matrix/read, _arg_memories_t_1_0_7, embedding_lookup/axis)]]

Caused by op 'embedding_lookup_6', defined at:
  File "/data/anaconda/envs/reco_base/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/data/anaconda/envs/reco_base/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelapp.py", line 563, in start
    self.io_loop.start()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 148, in start
    self.asyncio_loop.run_forever()
  File "/data/anaconda/envs/reco_base/lib/python3.6/asyncio/base_events.py", line 438, in run_forever
    self._run_once()
  File "/data/anaconda/envs/reco_base/lib/python3.6/asyncio/base_events.py", line 1451, in _run_once
    handle._run()
  File "/data/anaconda/envs/reco_base/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/ioloop.py", line 690, in <lambda>
    lambda f: self._run_callback(functools.partial(callback, future))
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 787, in inner
    self.run()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 748, in run
    yielded = self.gen.send(value)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 377, in dispatch_queue
    yield self.process_one()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 225, in wrapper
    runner = Runner(result, future, yielded)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 714, in __init__
    self.run()
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 748, in run
    yielded = self.gen.send(value)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 361, in process_one
    yield gen.maybe_future(dispatch(*args))
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 541, in execute_request
    user_expressions, allow_stdin,
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 300, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 536, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2848, in run_cell
    raw_cell, store_history, silent, shell_futures)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2874, in _run_cell
    return runner(coro)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/async_helpers.py", line 68, in _pseudo_sync_runner
    coro.send(None)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3051, in run_cell_async
    interactivity=interactivity, compiler=compiler, result=result)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3242, in run_ast_nodes
    if (await self.run_code(code, result,  async_=asy)):
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3319, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-17-b8b001ee6b13>", line 7, in <module>
    seed=seed)
  File "../../reco_utils/recommender/ripplenet/model.py", line 74, in __init__
    self._build_model()
  File "../../reco_utils/recommender/ripplenet/model.py", line 159, in _build_model
    tf.nn.embedding_lookup(self.entity_emb_matrix, self.memories_t[i])
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/embedding_ops.py", line 313, in embedding_lookup
    transform_fn=None)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/embedding_ops.py", line 133, in _embedding_lookup_and_transform
    result = _clip(array_ops.gather(params[0], ids, name=name),
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 2675, in gather
    return gen_array_ops.gather_v2(params, indices, axis, name=name)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3332, in gather_v2
    "GatherV2", params=params, indices=indices, axis=axis, name=name)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
    op_def=op_def)
  File "/data/anaconda/envs/reco_base/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1770, in __init__
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): indices[6,12] = 22991 is not in [0, 22908)
	 [[node embedding_lookup_6 (defined at ../../reco_utils/recommender/ripplenet/model.py:159)  = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_DOUBLE, _class=["loc:@Adam/Assign_1"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](entity_emb_matrix/read, _arg_memories_t_1_0_7, embedding_lookup/axis)]]

@miguelgfierro
I had that error in Colab as well, but it was fixed when I selected in Runtime Type the Hardware Accelerator as GPU

@miguelgfierro
Copy link
Collaborator

@almudenasanz I fixed the error, now everything computes correctly, however, the metrics looks too high, we should take a look

@miguelgfierro
Copy link
Collaborator

miguelgfierro commented Jan 22, 2020

so it looks that the problem is that we are scoring items that are already seen, that's why p@k and r@k are so high. In other algos, we have what we call predict which is for rating, and recommend_k_items, for ranking, an example: https://github.com/microsoft/recommenders/blob/master/reco_utils/recommender/sar/sar_singlenode.py#L433 https://github.com/microsoft/recommenders/blob/master/reco_utils/recommender/surprise/surprise_utils.py. In fact, they have different names depending on the algo, I'll try to fix that on a different PR #1039.

Almudena, can you please take a look at the remove seen example?

@miguelgfierro
Copy link
Collaborator

hey @almudenasanz, @loomlike found out that in the function convert_rating there is a modification of the original ratings to zero:

train_data.head()

  | user_index | item | rating | original_rating
-- | -- | -- | -- | --
0 | 341 | 1 | 5.0
0 | 3591 | 1 | 4.0
0 | 5725 | 0 | 0.0
0 | 1403 | 0 | 0.0
0 | 1581 | 0 | 0.0

but in movielens, there are no zeros, it goes from 1 to 5. So there has to be some error there

@almudenasanz
Copy link
Collaborator Author

In introduced new parameters for two functionalities:

  1. Remove items in test that were already seen in train. Although this did not affect our Movielens test because user-item pairs are unique

  2. Keep or remove scores below the threshold when building the ratings dataset. Also added a comment explaining that in the original paper the items below the threshold are removed:

Since MovieLens-1M and Book-Crossing are explicit feedback data, we transform them into implicit feedback where each entry is marked with 1 indicating that the user has rated the item (the threshold of rating is 4 for MovieLens-1M, while no threshold is set for Book-Crossing due to its sparsity), and sample an unwatched set marked as 0 for each user, which is of equal size with the rated ones.

I think we can run it with 1M and it would be ready

@miguelgfierro
Copy link
Collaborator

hey @almudenasanz I rerun with 100k movielens, still there is an error in the ranking metrics. Please take a look

@miguelgfierro
Copy link
Collaborator

hey @almudenasanz, this PR has been active since December. I think we should split this PR to have the AUC and accuracy that matches the paper and merge it. Later, on a different PR, we can take a look at the ranking metrics that are not providing good results.
Would this be ok?

@almudenasanz
Copy link
Collaborator Author

Hi @miguelgfierro I agree, I would just remove the cells with the precision_at_k and recall_at_k and reproduce with 1M

@miguelgfierro miguelgfierro mentioned this pull request Oct 19, 2022
2 tasks
@AdityaSoni19031997
Copy link
Contributor

AdityaSoni19031997 commented Oct 26, 2022

Hey @miguelgfierro!

Do we plan to release the Ripple-Net without the precision_at_k and recall_at_k metrics and then fix the ranking metrics by finding the source of error?

Thanks

Edits -> I wish the src was in PyTorch rather than tf 🤐 . Secondly, How to get access to Wiki's KG?

@miguelgfierro
Copy link
Collaborator

hey @AdityaSoni19031997, answering your questions:

Do we plan to release the Ripple-Net without the precision_at_k and recall_at_k metrics and then fix the ranking metrics by finding the source of error?

that sounds good

I wish the src was in PyTorch rather than tf

This notebook was done years ago when we were using TF1, now we are using TF2. You could either use TF2 or if you want, implement it in PyTorch (there is an implementation https://github.com/qibinc/RippleNet-PyTorch). In general, we prefer PyTorch over TF.

How to get access to Wiki's KG?

The KG is generated from this notebook https://github.com/microsoft/recommenders/blob/ad0bc93142586dd1b856f9bb8629c89947c93235/notebooks/01_prepare_data/wikidata_knowledge_graph.ipynb
but we actually have already generated it:

kg_original = pd.read_csv("https://recodatasets.blob.core.windows.net/wikidata/movielens_{}_wikidata.csv".format(MOVIELENS_DATA_SIZE))
kg_original.head(3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants