(questions, answers, ctable)
return X, y
Vectorize the data as numpy arrays
Vectorize the data as numpy arrays
Vectorize the data as numpy arrays
def _vectorize(questions, answers, ctable):
    """Vectorize the data as numpy arrays"""
    len_of_questions = len(questions)
    X = np_zeros((len_of_questions, CONFIG.max_input_len, ctable.size), dtype=np.bool)
    for i in xrange(len(questions)):
        sentence = questions.pop()
        for j, c in enumerate(sentence):
            try:
                X[i, j, ctable.char_indices[c]] = 1
            except KeyError:
                pass # Padding
    y = np_zeros((len_of_questions, CONFIG.max_input_len, ctable.size), dtype=np.bool)
    for i in xrange(len(answers)):
        sentence = answers.pop()
        for j, c in enumerate(sentence):
            try:
                y[i, j, ctable.char_indices[c]] = 1
            except KeyError:
                pass # Padding
    return X, y
def _vectorize ( questions , answers , ctable ) : len_of_questions = len ( questions ) X = np_zeros ( ( len_of_questions , CONFIG . max_input_len , ctable . size ) , dtype = np . bool ) for i in xrange ( len ( questions ) ) : sentence = questions . pop ( ) for j , c in enumerate ( sentence ) : try : X [ i , j , ctable . char_indices [ c ] ] = 1 except KeyError : pass # Padding y = np_zeros ( ( len_of_questions , CONFIG . max_input_len , ctable . size ) , dtype = np . bool ) for i in xrange ( len ( answers ) ) : sentence = answers . pop ( ) for j , c in enumerate ( sentence ) : try : y [ i , j , ctable . char_indices [ c ] ] = 1 except KeyError : pass # Padding return X , y