MCPcopy Index your code
hub / github.com/lisa-lab/DeepLearningTutorials / pred_error

Function pred_error

code/lstm.py:429–445  ·  view source on GitHub ↗

Just compute the error f_pred: Theano fct computing the prediction prepare_data: usual prepare_data for that dataset.

(f_pred, prepare_data, data, iterator, verbose=False)

Source from the content-addressed store, hash-verified

427
428
429def pred_error(f_pred, prepare_data, data, iterator, verbose=False):
430 """
431 Just compute the error
432 f_pred: Theano fct computing the prediction
433 prepare_data: usual prepare_data for that dataset.
434 """
435 valid_err = 0
436 for _, valid_index in iterator:
437 x, mask, y = prepare_data([data[0][t] for t in valid_index],
438 numpy.array(data[1])[valid_index],
439 maxlen=None)
440 preds = f_pred(x, mask)
441 targets = numpy.array(data[1])[valid_index]
442 valid_err += (preds == targets).sum()
443 valid_err = 1. - numpy_floatX(valid_err) / len(data[0])
444
445 return valid_err
446
447
448def train_lstm(

Callers 1

train_lstmFunction · 0.85

Calls 2

prepare_dataFunction · 0.85
numpy_floatXFunction · 0.85

Tested by

no test coverage detected