Closed ToneLi closed 4 years ago
Hi Tone,
The "next" function will always give the next item in a "python iterator" (please search "python iterator" in Google for python syntax)
list and dict are not "python iterators".
Hi Sun, Thanks very much! Chen~
Zhiqing Sun notifications@github.com 于2020年7月1日周三 下午9:43写道:
Hi Tone,
The "next" function will always give the next item in a "python iterator" (please search "python iterator" in Google for python syntax)
list and dict are not "python iterators".
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DeepGraphLearning/KnowledgeGraphEmbedding/issues/29#issuecomment-652426432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AICJYNPMIACNSSXDTJ4GVSTRZM4PHANCNFSM4OL6XHLQ .
I have question in (ROTATE) model.py. ROTATE uses next function to generate the data, shouldn't the next function be inside the loop? If use this function, I found in every step, ROTATE just chooses the first batch to train, because if next function is not in the loop, it will generates the first data in the list/dict.... who can help me answer my question?
class BidirectionalOneShotIterator(object):
def train_step(model, optimizer, train_iterator, args): ''' A single train step. Apply back-propation and return the loss ''' model.train() optimizer.zero_grad() positive_sample, negative_sample, subsampling_weight, mode = next(train_iterator)