parameters: (x, y)
return_statement: return {'class': tf.argmax(prediction, 1), 'prob': prediction}, loss, train_op
docstring: A bag-of-words model. Note it disregards the word order in the text.
docstring_summary: A bag-of-words model. Note it disregards the word order in the text.
docstring_tokens: A bag - of - words model . Note it disregards the word order in the text .
function: def bag_of_words_model(x, y):
    """A bag-of-words model. Note it disregards the word order in the text."""
    target = tf.one_hot(y, 15, 1, 0)
    word_vectors = learn.ops.categorical_variable(x, n_classes=n_words,
        embedding_size=EMBEDDING_SIZE, name='words')
    features = tf.reduce_max(word_vectors, reduction_indices=1)
    prediction, loss = learn.models.logistic_regression(features, target)
    train_op = tf.contrib.layers.optimize_loss(
        loss, tf.contrib.framework.get_global_step(),
        optimizer='Adam', learning_rate=0.01)
    return {'class': tf.argmax(prediction, 1), 'prob': prediction}, loss, train_op
function_tokens: def bag_of_words_model ( x , y ) : target = tf . one_hot ( y , 15 , 1 , 0 ) word_vectors = learn . ops . categorical_variable ( x , n_classes = n_words , embedding_size = EMBEDDING_SIZE , name = 'words' ) features = tf . reduce_max ( word_vectors , reduction_indices = 1 ) prediction , loss = learn . models . logistic_regression ( features , target ) train_op = tf . contrib . layers . optimize_loss ( loss , tf . contrib . framework . get_global_step ( ) , optimizer = 'Adam' , learning_rate = 0.01 ) return { 'class' : tf . argmax ( prediction , 1 ) , 'prob' : prediction } , loss , train_op