yongqyu / strnn Goto Github PK
View Code? Open in Web Editor NEWPredicting the Next Location: A Recurrent Model with Spatial and Temporal Contexts
Predicting the Next Location: A Recurrent Model with Spatial and Temporal Contexts
Thank you for releasing the code, after running preprocess.py, I ran train_torch.py, but at 78% of first epoch, I got this error, any suggestion on solving this error? Many thanks.
Environment information:
OS: 16.04.5
python 3.5.2
pytorch 0.4.0
GPU: nvidia gtx1070
smiles@smiles:~/keli/STRNN$ python3 train_torch.py
Loading data...
User/Location: 32899/1115406/42133
==================================================================================
train: 78%|███████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 32815/42133 [1:29:11<13:29, 11.51it/s]/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [0,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [1,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [2,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [3,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [4,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [5,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [6,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [7,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [8,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [9,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [10,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [11,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/THC/THCTensorIndex.cu:306: void indexSelectSmallIndex(TensorInfo<T, IndexType>, TensorInfo<T, IndexType>, TensorInfo<long, IndexType>, int, int, IndexType, long) [with T = float, IndexType = unsigned int, DstDim = 2, SrcDim = 2, IdxDim = -2]: block: [0,0,0], thread: [12,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
THCudaCheck FAIL file=/pytorch/aten/src/THC/generated/../THCReduceAll.cuh line=339 error=59 : device-side assert triggered
Traceback (most recent call last):
File "train_torch.py", line 202, in <module>
total_loss += run(batch_user, batch_td, batch_ld, batch_loc, batch_dst, step=1)
File "train_torch.py", line 181, in run
J = strnn_model.loss(user, td_upper, td_lower, ld_upper, ld_lower, location, destination, rnn_output)#, neg_lati, neg_longi, neg_loc, step)
File "train_torch.py", line 101, in loss
l2_reg.append(W.norm(2))
RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generated/../THCReduceAll.cuh:339
Exception ignored in: <bound method tqdm.__del__ of train: 78%|███████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 32815/42133 [1:29:11<13:29, 11.51it/s]>
Traceback (most recent call last):
File "/home/smiles/.local/lib/python3.5/site-packages/tqdm/_tqdm.py", line 889, in __del__
self.close()
File "/home/smiles/.local/lib/python3.5/site-packages/tqdm/_tqdm.py", line 1095, in close
self._decr_instances(self)
File "/home/smiles/.local/lib/python3.5/site-packages/tqdm/_tqdm.py", line 454, in _decr_instances
cls.monitor.exit()
File "/home/smiles/.local/lib/python3.5/site-packages/tqdm/_monitor.py", line 52, in exit
self.join()
File "/usr/lib/python3.5/threading.py", line 1051, in join
raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
Hi Yonggyu Park,
I notice that this code is the baseline of your paper Content-Aware Hierarchical Point-of-Interest Embedding Model for Successive POI Recommendation. It looks you have got a rather good performance for st-rnn that recall@1 is 0.1054. So I wonder if you have any idea about tuning the parameters on Gowalla datasets because this recall performance is largely lower than the original paper and your paper.
Thanks!
Theo
Could you help me? Thank you very much!!!!
After having Gowallat ../dataset/.
then
$ python preprocess.py
I got error like this:IndexError: too many indices for array
Making train file...
train: 0%| | 0/42241 [00:00<?, ?it/s]
Traceback (most recent call last):
File "./preprocess.py", line 148, in
run(train_user[j], batch_time, batch_lati, batch_longi, batch_loc, step=1)
File "./preprocess.py", line 137, in run
rnn_output = strnn_model(user, time, lati, longi, loc, step)#, neg_lati, neg_longi, neg_loc, step)
File "/home/swim/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "./preprocess.py", line 126, in forward
pos_h = self.return_h_tw(times, latis, longis, locs, len(times)-1)
File "./preprocess.py", line 89, in return_h_tw
self.return_h_tw(times, latis, longis, locs, w_cap)
File "./preprocess.py", line 89, in return_h_tw
self.return_h_tw(times, latis, longis, locs, w_cap)
File "./preprocess.py", line 89, in return_h_tw
self.return_h_tw(times, latis, longis, locs, w_cap)
[Previous line repeated 136 more times]
File "./preprocess.py", line 100, in return_h_tw
data = ','.join(str(e.data.cpu().numpy()[0]) for e in locs[w_cap:idx])+"\t"
File "./preprocess.py", line 100, in
data = ','.join(str(e.data.cpu().numpy()[0]) for e in locs[w_cap:idx])+"\t"
IndexError: too many indices for array
这个实现的STRNN效果和论文比是一样吗?比论文差?
Hi,
Is there any difference between your validation and test set? You passed them into a method.
Hi Yongqyu,
Thank you for re-implementing ST-RNN. I am quite interested in it. However, I find that the recall performances are largely lower than the figures given in the paper.
My results (15 epochs):
('recall@1: ', 0.0010507880910683013)
('recall@5: ', 0.0051138353765324)
('recall@10: ', 0.00903677758318739)
('recall@100: ', 0.025218914185639228)
('recall@1000: ', 0.0533800350262697)
('recall@10000: ', 0.09936952714535902)
Results in the paper:
recall@1 0.0304,
recall@5 0.1524
recall@10 0.2714
It seems that the model is overfitting. And I noticed that your regulation parameter is set to be 0.0005, but the author set this parameter to be 0.01. I'll try 0.01 shortly.
By the way, what is your opinion about this performance difference?
Thanks,
Charles
What changes should be made to implement this code on the GTD?
论文里面对ht的计算是使用了下一个POI与lastPOI的时空间间隔,但是在validation那里使用的时空间间隔貌似只用到了dst与lastPOI的时空间间隔,并没有计算所有POI与lastPOI的时空间间隔,是我理解错误了吗
Sorry to bother you.
When I tried to use the processed dataset to train,it runned very well,but when I was trying to use the 'preprocess.py' to cut the dataset 'Gowalla_totalCheckins.txt', an error has occurred, “too many indices for array“ ,line 100,finally i have fixed it ,in line 100 and 102 you need to delete '[0]' .
data = ','.join(str(e.data.cpu().numpy()) for e in locs[w_cap:idx])+"\t"
f.write(data)
data = str(locs[idx].data.cpu().numpy())+"\n"
f.write(data)
Does the result shows in README run on Gowalla dataset?
In train_torch.py line 98-104, the loss function is implemented as
def loss(self, user, td_upper, td_lower, ld_upper, ld_lower, loc, dst, hx):
h_tq = self.forward(td_upper, td_lower, ld_upper, ld_lower, loc, hx)
p_u = self.permanet_weight(user)
q_v = self.location_weight(dst)
output = torch.mm(q_v, (h_tq + torch.t(p_u)))
return torch.log(1+torch.exp(torch.neg(output)))
However, in the paper, the loss function is as following
I thought output in the codes refers to Ou,v,t but where is Ou,v,t' in codes? Meanwhile, it seems the regulation part is not considered as well.
Thank you for the implemention of ST-RNN.I have get some questions about the code.
How do you choose value for the time unper bound of low bound ? And the dst unper bound and low bound.
given a user's trajectory ,how could you handle the trajectory and make each check_in ( user, lat,lng, time-stamp) into user-td,user-ld,user-loc,user-dst.
I want to know how the loc_len is calculated.For example,if the window width is 6h,and three check-in is within 6 h,such as A ,B,C, then A 's loc_len is 1, B's loc_len is 2, C's loc_len is 3?
I would appreciate it a lot if you could help me.Best wishes to you.Cause I have to know the answers to preprocess my
Hi, yongqyu
Sorry to bother you. Recently i want to compare my work with strnn. If i want to use prediction precision to evaluate this model in your code. How can i modify? Can you give me some advice?
Very thanks
Hi Yongqyu,
Thank you for re-implementing ST-RNN. I am quite interested in it. However, I have some questions about the Gowalla dataset in the file prepro_train_50.txt. The code says that time_window=360 minutes, but in the first column of the file prepro_train_50.txt have some time interval greater than 360 minutes:
1
82.25 0.331054 133 132
1297.62 0.109035 132 131
382.5,321.375,32.5625 0.0926226,0.0924566,0.00229809 131,130,129 128
3783.62 9.29145 128 6
1942.94 0.00119504 6 1
3338.06 25.7679 1 127
2272.69 25.7676 127 35
By the way, what is your opinion about this ?
Thanks,
Liu zhuang
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.