# _, _, _, newLoss, newWords = doForwardPass(current) # devLoss += newLoss # devWords += newWords # return devLoss/devWords #dhGradients_WSurp = deque(maxlen=50000) # * corpus.length()) #distanceGradients_WSurp = deque(maxlen=50000) # * corpus.length()) assert batchSize == 1 depLengths = [] #while True: if True: corpus = CorpusIteratorFuncHead(language, "train") corpusIterator = corpus.iterator() if corpus.length() == 0: quit() while True: try: batch = map(lambda x: next(corpusIterator), 10 * range(batchSize)) except StopIteration: break batch = sorted(batch, key=len) partitions = range(10) shuffle(partitions) for partition in partitions: counter += 1 printHere = (counter % 100 == 0) current = batch[partition * batchSize:(partition + 1) * batchSize]
if wordNum > 0: crossEntropy = 0.99 * crossEntropy + 0.01 * (totalDepLength/wordNum) else: assert totalDepLength == 0 numberOfWords = wordNum return (totalDepLength, numberOfWords, byType) assert batchSize == 1 depLengths = [] if True: corpus = CorpusIteratorFuncHead(args.language,"train") corpusIterator = corpus.iterator() if corpus.length() == 0: quit() while True: try: batch = [next(corpusIterator)] except StopIteration: break partitions = range(1) for partition in partitions: counter += 1 printHere = (counter % 200 == 0) current = batch[partition*batchSize:(partition+1)*batchSize] if len(current) == 0: continue depLength = doForwardPass(current)
# # _, _, _, newLoss, newWords = doForwardPass(current) # devLoss += newLoss # devWords += newWords # return devLoss/devWords #dhGradients_WSurp = deque(maxlen=50000) # * corpus.length()) #distanceGradients_WSurp = deque(maxlen=50000) # * corpus.length()) assert batchSize == 1 depLengths = [] while True: corpus = CorpusIteratorFuncHead(language, "train") corpusIterator = corpus.iterator() if corpus.length() == 0: quit() while True: try: batch = map(lambda x: next(corpusIterator), 10 * range(batchSize)) except StopIteration: break batch = sorted(batch, key=len) partitions = range(10) shuffle(partitions) for partition in partitions: counter += 1 printHere = (counter % 20 == 0) current = batch[partition * batchSize:(partition + 1) * batchSize]