gabrielspmoreira / chameleon_recsys

Source code of CHAMELEON - A Deep Learning Meta-Architecture for News Recommender Systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Shape mismatch" while running run_nar_train_adressa_local.sh

Heng-xiu opened this issue · comments

ERROR:tensorflow:ERROR: shape mismatch in assignment
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/hengshiou/Documents/chameleon_recsys/nar_module/nar/nar_trainer_adressa.py", line 573, in <module>
    tf.app.run()
  File "/usr/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/usr/lib/python3.7/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/usr/lib/python3.7/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "/home/hengshiou/Documents/chameleon_recsys/nar_module/nar/nar_trainer_adressa.py", line 497, in main
    model.train(input_fn=lambda: prepare_dataset_iterator(training_files_chunk, session_features_config,
  File "/usr/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 367, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/usr/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1158, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/usr/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1192, in _train_model_default
    saving_listeners)
  File "/usr/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1484, in _train_with_estimator_spec
    _, loss = mon_sess.run([estimator_spec.train_op, estimator_spec.loss])
  File "/usr/lib/python3.7/site-packages/tensorflow/python/training/monitored_session.py", line 754, in run
    run_metadata=run_metadata)
  File "/usr/lib/python3.7/site-packages/tensorflow/python/training/monitored_session.py", line 1252, in run
    run_metadata=run_metadata)
  File "/usr/lib/python3.7/site-packages/tensorflow/python/training/monitored_session.py", line 1353, in run
    raise six.reraise(*original_exc_info)
  File "/usr/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/lib/python3.7/site-packages/tensorflow/python/training/monitored_session.py", line 1338, in run
    return self._sess.run(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/tensorflow/python/training/monitored_session.py", line 1419, in run
    run_metadata=run_metadata))
  File "/home/hengshiou/Documents/chameleon_recsys/nar_module/nar/nar_model.py", line 1659, in after_run
    self.clicked_items_state.update_items_coocurrences(batch_clicked_items)
  File "/home/hengshiou/Documents/chameleon_recsys/nar_module/nar/nar_model.py", line 1371, in update_items_coocurrences
    self.items_coocurrences[rows, cols] += 1
  File "/usr/lib/python3.7/site-packages/scipy/sparse/_index.py", line 124, in __setitem__
    raise ValueError("shape mismatch in assignment")
ValueError: shape mismatch in assignment

Hi there, would you mind clarifying the issue right here? "the shape mismatch in assignment." I follow the given instruction on the README

replace self.items_coocurrences[rows, cols] += 1 with following code.

for r,c in zip(rows, cols):
    self.items_coocurrences[r, c] += 1

replace self.items_coocurrences[rows, cols] += 1 with following code.

for r,c in zip(rows, cols):
    self.items_coocurrences[r, c] += 1

good job, it works for me !

It works for me, too.