(file_name)
Returns a tuple (inputs, targets)
    All arrays should contain the same number of samples.
    The generator is expected to loop over its data indefinitely.
    An epoch finishes when  samples_per_epoch samples have been seen by the model.
Returns a tuple (inputs, targets)
    All arrays should contain the same number of samples.
    The generator is expected to loop over its data indefinitely.
    An epoch finishes when  samples_per_epoch samples have been seen by the model.
Returns a tuple ( inputs targets ) All arrays should contain the same number of samples . The generator is expected to loop over its data indefinitely . An epoch finishes when samples_per_epoch samples have been seen by the model .
def generator(file_name):
    """Returns a tuple (inputs, targets)
    All arrays should contain the same number of samples.
    The generator is expected to loop over its data indefinitely.
    An epoch finishes when  samples_per_epoch samples have been seen by the model.
    """
    ctable = CharacterTable(read_top_chars())
    batch_of_answers = []
    while True:
        with open(file_name) as answers:
            for answer in answers:
                batch_of_answers.append(answer.strip().decode('utf-8'))
                if len(batch_of_answers) == CONFIG.batch_size:
                    random_shuffle(batch_of_answers)
                    batch_of_questions = []
                    for answer_index, answer in enumerate(batch_of_answers):
                        question, answer = generate_question(answer)
                        batch_of_answers[answer_index] = answer
                        assert len(answer) == CONFIG.max_input_len
                        question = question[::-1] if CONFIG.inverted else question
                        batch_of_questions.append(question)
                    X, y = _vectorize(batch_of_questions, batch_of_answers, ctable)
                    yield X, y
                    batch_of_answers = []
def generator ( file_name ) : ctable = CharacterTable ( read_top_chars ( ) ) batch_of_answers = [ ] while True : with open ( file_name ) as answers : for answer in answers : batch_of_answers . append ( answer . strip ( ) . decode ( 'utf-8' ) ) if len ( batch_of_answers ) == CONFIG . batch_size : random_shuffle ( batch_of_answers ) batch_of_questions = [ ] for answer_index , answer in enumerate ( batch_of_answers ) : question , answer = generate_question ( answer ) batch_of_answers [ answer_index ] = answer assert len ( answer ) == CONFIG . max_input_len question = question [ : : - 1 ] if CONFIG . inverted else question batch_of_questions . append ( question ) X , y = _vectorize ( batch_of_questions , batch_of_answers , ctable ) yield X , y batch_of_answers = [ ]