Esempio n. 1
0
#loop over each training example
for x, y in train_data.items():
    inputs = createInputs(x)
    target = int(y)

#Forward
    out, __ = rnn.forward(inputs)
    probs = softmax(out)

    #Build dL/dy
    d_L_d_y = probs
    d_L_d_y -= 1

    #Backward
    rnn.backprop(d_L_d_y)




def processData(data, backprop = True):
    '''
    Returns the RNN's loss and accuracy for the given data.
   - data is a dictionary mapping text to True or False.
   - backprop determines if the backward phase should be run.
    '''
	items = list(data.items())
	random.shuffle(items)

	loss = 0
	num_correct = 0