(questions, answers, chars=None)
return X_train, X_val, y_train, y_val, CONFIG.max_input_len, ctable
Vectorize the questions and expected answers
Vectorize the questions and expected answers
Vectorize the questions and expected answers
def vectorize(questions, answers, chars=None):
    """Vectorize the questions and expected answers"""
    print('Vectorization...')
    chars = chars or CHARS
    ctable = CharacterTable(chars)
    X, y = _vectorize(questions, answers, ctable)
    # Explicitly set apart 10% for validation data that we never train over
    split_at = int(len(X) - len(X) / 10)
    (X_train, X_val) = (slice_X(X, 0, split_at), slice_X(X, split_at))
    (y_train, y_val) = (y[:split_at], y[split_at:])

    print(X_train.shape)
    print(y_train.shape)

    return X_train, X_val, y_train, y_val, CONFIG.max_input_len, ctable
def vectorize ( questions , answers , chars = None ) : print ( 'Vectorization...' ) chars = chars or CHARS ctable = CharacterTable ( chars ) X , y = _vectorize ( questions , answers , ctable ) # Explicitly set apart 10% for validation data that we never train over split_at = int ( len ( X ) - len ( X ) / 10 ) ( X_train , X_val ) = ( slice_X ( X , 0 , split_at ) , slice_X ( X , split_at ) ) ( y_train , y_val ) = ( y [ : split_at ] , y [ split_at : ] ) print ( X_train . shape ) print ( y_train . shape ) return X_train , X_val , y_train , y_val , CONFIG . max_input_len , ctable