<commit_before>import numpy as np
import tensorflow as tf
from tensorflow.models.rnn import rnn, rnn_cell
from BiRNN import BiRNN
from data_handler import pull_data_chunk

learn_rate = 0.001
training_iterations = 10000
log_frequency = 100

n_hidden = 64
n_classes = 36

x = tf.placeholder("float", [None, n_steps, n_input])
y = tf.placeholder("float", [None, n_classes])

weights = {
    'out': tf.Variable(tf.random_normal([2*n_hidden, n_classes]))
}
biases = {
    'out': tf.Variable(tf.random_normal([n_classes]))
}

pred = BiRNN(x, weights, biases)
#print pred

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)

correct_pred = tf.equal(tf.argmax(pred,1), tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))

init = tf.initialize_all_variables()

with tf.Session() as sess:
	sess.run(init)
	step = 1
	while step < training_iterations:
		xtrain, ytrain = pull_data_chunk()<commit_msg>Add optimization loop with backprop<commit_after>import numpy as np
import tensorflow as tf
from tensorflow.models.rnn import rnn, rnn_cell
from BiRNN import BiRNN
from data_handler import pull_data_chunk

learn_rate = 0.001
training_iterations = 10000
log_frequency = 100

n_hidden = 64
n_classes = 36

x = tf.placeholder("float", [None, n_steps, n_input])
y = tf.placeholder("float", [None, n_classes])

weights = {
    'out': tf.Variable(tf.random_normal([2*n_hidden, n_classes]))
}
biases = {
    'out': tf.Variable(tf.random_normal([n_classes]))
}

pred = BiRNN(x, weights, biases)
#print pred

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)

correct_pred = tf.equal(tf.argmax(pred,1), tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))

init = tf.initialize_all_variables()

with tf.Session() as sess:
	sess.run(init)
	step = 1
	while step < training_iterations:
		xtrain, ytrain = pull_data_chunk()
		sess.run(optimizer, feed_dict={x: xtrain, y: ytrain})
		if step % log_frequency == 0:
			acc = sess.run(accuracy, feed_dict={x: xtrain, y: ytrain})
			loss = sess.run(cost, feed_dict={x: xtrain, y: ytrain})
			print "Iteration: ", step, "\Accuracy: ", acc, "\Loss: ", loss
		step += 1

{'fraction_non_alphanumeric': 0.13184931506849315, 'fraction_numerical': 0.019691780821917807, 'mean_word_length': 5.564606741573034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1110197', 'n_tokens_mistral': 919, 'n_tokens_neox': 862, 'n_words': 191}