songweiping / gru4rec_tensorflow Goto Github PK
View Code? Open in Web Editor NEWTensorFlow implemenation of GRu4Rec model
TensorFlow implemenation of GRu4Rec model
It seems "top1" loss function do not work in this tf implementation?
I follow the parameters setting like that it theano implementation. However, I just get a result of 0.48 and 0.17. (Original is 0.59 and 0.23)
I use tensorflow 1.2.
在model.py#L136中,注释写道:Use other examples of the minibatch as negative samples.
请问如何通过softmax和sampled_W,sampled_b进行负采样的呢?
水平有限,希望大佬不吝赐教~
您好,我在运行这篇文章的代码时,训练的结果是这样的:当lr=0.000017 loss=1.4135(最小),随后当lr=0.000010(之后一直不变),随着step增大,loss也在逐渐增大。这种现象正常吗?或者怎么解释呢?我是这方面的小白,望多包涵。谢谢!
@Songweiping 您好
很感谢您特地写了一个tensorflow版本的GRU4Rec,真的很浅显易懂
我在每次training step时,用本篇evaluation的方法查看traing时的recall变化
我发现每次recall都接近1
请问这样是正常的现象吗
Data format is same as provided but my validation loss is coming out to be nan and finally best loss is recorded as default=100
Connected to pydev debugger (build 183.5153.39)
0.5
Traceback (most recent call last):
File "/home/syh/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5153.39/helpers/pydev/pydevd.py", line 1741, in <module>
main()
File "/home/syh/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5153.39/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/syh/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5153.39/helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/run/media/syh/0D11080D0D11080D/workspace/Recommender-System/exp/GRU4Rec_TensorFlow-master/main.py", line 82, in <module>
gru.fit(data)
File "/run/media/syh/0D11080D0D11080D/workspace/Recommender-System/exp/GRU4Rec_TensorFlow-master/model.py", line 190, in fit
offset_sessions = self.init(data)
File "/run/media/syh/0D11080D0D11080D/workspace/Recommender-System/exp/GRU4Rec_TensorFlow-master/model.py", line 178, in init
data.sort_index([self.session_key, self.time_key], inplace=True)
File "/run/media/syh/0D11080D0D11080D/workspace/Recommender-System/exp/venv/lib/python2.7/site-packages/pandas/core/frame.py", line 2952, in sort_index
axis = self._get_axis_number(axis)
File "/run/media/syh/0D11080D0D11080D/workspace/Recommender-System/exp/venv/lib/python2.7/site-packages/pandas/core/generic.py", line 293, in _get_axis_number
axis = self._AXIS_ALIASES.get(axis, axis)
TypeError: unhashable type: 'list'
Environment: Manjaro Python 2.7
Hello, @Songweiping
I use the processed data processed from: https://github.com/hidasib/GRU4Rec
When I run this main.py, but I get this error:
I am wondering what cause this? Could you give me some advice?
data = pd.merge(data, pd.DataFrame({self.item_key:itemids, 'ItemIdx':self.itemidmap[itemids].values}), on=self.item_key, how='inner')
After merged with pd.DataFrame({self.item_key:itemids, 'ItemIdx':self.itemidmap[itemids].values}), the data 's order is based on itemidx order. So I think the code for processing data after is not true.
Could you explain used python libraries in detail in the Requirements or release a requirements.txt file ?
PATH_TO_TRAIN = '/PATH/TO/rsc15_train_full.txt'
PATH_TO_TEST = '/PATH/TO/rsc15_test.txt'
你好,请问这个方法有在真实的推荐场景中使用吗?还有考虑过加入用户维度的信息吗?谢谢
Hello, Song,
I found a problem in this kind of process.
In your evaluation.py:
I note that you picked ">" here, but if we use tanh as the final activation function, many scores of this preds may be equal to 1 for each user. And that means many scores of items are in one position at the same time. But this trick is unreasonable, because we cannot rank these items. If you use >=, the performance will be bad.
I think this is the implement in the original Hidash's code. So what do you think of this?
Looking forward to your reply.
Thank you ~
Restore model from save/lstm_p0.7_rnn100_batch16_unfold8 successfully!
Traceback (most recent call last):
File "test.py", line 104, in
res = evaluate(args)
File "test.py", line 83, in evaluate
joblib.dump(model, joblib_file)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 502, in dump
NumpyPickler(f, protocol=protocol).dump(value)
File "//anaconda3/lib/python3.7/pickle.py", line 437, in dump
self.save(obj)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "//anaconda3/lib/python3.7/pickle.py", line 662, in save_reduce
save(state)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "//anaconda3/lib/python3.7/pickle.py", line 856, in save_dict
self._batch_setitems(obj.items())
File "//anaconda3/lib/python3.7/pickle.py", line 882, in _batch_setitems
save(v)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "//anaconda3/lib/python3.7/pickle.py", line 662, in save_reduce
save(state)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "//anaconda3/lib/python3.7/pickle.py", line 856, in save_dict
self._batch_setitems(obj.items())
File "//anaconda3/lib/python3.7/pickle.py", line 882, in _batch_setitems
save(v)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "//anaconda3/lib/python3.7/pickle.py", line 662, in save_reduce
save(state)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "//anaconda3/lib/python3.7/pickle.py", line 856, in save_dict
self._batch_setitems(obj.items())
File "//anaconda3/lib/python3.7/pickle.py", line 882, in _batch_setitems
save(v)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "//anaconda3/lib/python3.7/pickle.py", line 662, in save_reduce
save(state)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "//anaconda3/lib/python3.7/pickle.py", line 856, in save_dict
self._batch_setitems(obj.items())
File "//anaconda3/lib/python3.7/pickle.py", line 882, in _batch_setitems
save(v)
File "//anaconda3/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 292, in save
return Pickler.save(self, obj)
File "//anaconda3/lib/python3.7/pickle.py", line 524, in save
rv = reduce(self.proto)
TypeError: can't pickle _thread.RLock objects
J
请问,代码中为什么没有使用验证集(从训练集中划分出来的验证集)来设置模型训练过程的early stop?貌似代码中的验证过程用的是test数据集 。 @Songweiping
hello Dr.Song,my question is about the session_id.
Should different user share the same session_id?
let's say if user_a have 5 sessions which has session_id in 0-4,and user_b also have 5 sessions, the session_id of user_b should also be 0-4 or should them be 5-9?
thx
looking forward to your reply
特地开 issue 感谢宋博士!
原本还想着自己写个 TF 版本的,巧了!
Line 128 in dd04a89
When constructing a MultiRNNCell with this statement, tensorflow will prompt that multiple cells are actually sharing weights.
So I think the correct build method should look like this:
cells = []
for i in range(self.layers):
cell = rnn_cell.GRUCell(num_units=self.rnn_size, activation=self.hidden_act)
cell = rnn_cell.DropoutWrapper(cell, output_keep_prob=self.dropout_p_hidden)
cells.append(cell)
multi_cell = rnn_cell.MultiRNNCell(cells)
hi,
请问,在 GRU4Rec.cross_entrop 函数(line 98)中,tf.diag_part 只提取了对角线上的元素,这样是否会导致loss function只计算了正例的loss, 而没有计算负例的loss?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.