Comments (2)
i noticed that this error is occuring when all the 500 test examples are yielded and there is calling the next() method on this causes this error. But i still don't know how can i resolve this error.
from sequence-based-recommendations.
i fixed it by the help of https://stackoverflow.com/questions/51700960/runtimeerror-generator-raised-stopiteration-every-time-i-try-to-run-app
i changed
while True:
j = 0
sequences = []
batch_size = self.batch_size
if test:
batch_size = 1
while j < batch_size:
sequence, user_id = next(sequence_generator)
# print('sequence: ', sequence)
# print('user_id: ', user_id, 'test: ', test)
# pdb.set_trace()
# finds the lengths of the different subsequences
if not test:
seq_lengths = sorted(random.sample(range(2, len(sequence)), min([batch_size - j, len(sequence) - 2, max_reuse_sequence])))
else:
seq_lengths = [int(len(sequence) / 2)]
skipped_seq = 0
for l in seq_lengths:
target = self.target_selection(sequence[l:], test=test)
if len(target) == 0:
skipped_seq += 1
continue
start = max(0, l - self.max_length) # sequences cannot be longer than self.max_lenght
sequences.append([user_id, sequence[start:l], target])
j += len(seq_lengths) - skipped_seq
if test:
# sequence[seq_lengths[0]:] is the sequence (ratings included) GT here
# [i[0] for i in sequence[seq_lengths[0]:]] is the GT here (ratings excluded)
yield self._prepare_input(sequences), [i[0] for i in sequence[seq_lengths[0]:]]
else:
yield self._prepare_input(sequences)
to
while True:
try:
j = 0
sequences = []
batch_size = self.batch_size
if test:
batch_size = 1
while j < batch_size:
sequence, user_id = next(sequence_generator)
# print('sequence: ', sequence)
# print('user_id: ', user_id, 'test: ', test)
# pdb.set_trace()
# finds the lengths of the different subsequences
if not test:
seq_lengths = sorted(random.sample(range(2, len(sequence)), min([batch_size - j, len(sequence) - 2, max_reuse_sequence])))
else:
seq_lengths = [int(len(sequence) / 2)]
skipped_seq = 0
for l in seq_lengths:
target = self.target_selection(sequence[l:], test=test)
if len(target) == 0:
skipped_seq += 1
continue
start = max(0, l - self.max_length) # sequences cannot be longer than self.max_lenght
sequences.append([user_id, sequence[start:l], target])
j += len(seq_lengths) - skipped_seq
if test:
# sequence[seq_lengths[0]:] is the sequence (ratings included) GT here
# [i[0] for i in sequence[seq_lengths[0]:]] is the GT here (ratings excluded)
yield self._prepare_input(sequences), [i[0] for i in sequence[seq_lengths[0]:]]
else:
yield self._prepare_input(sequences)
except StopIteration:
return
from sequence-based-recommendations.
Related Issues (17)
- Bug in code
- low sps performace HOT 1
- Import 'rnn_base' Error HOT 1
- Strange training statistics
- when run preprocess.py, it occurs some problems
- too long time about running HOT 2
- padding value of 0 is the same as one of the movie IDs in movielens 1 million dataset
- Incremental Training
- some questions about rnn HOT 16
- some questions about the recommendations HOT 2
- about running time HOT 8
- What is the meaning of sas in the results? HOT 3
- next basket recommendation HOT 2
- License? HOT 1
- question with the rnn input sequence
- The means of ndcg HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sequence-based-recommendations.