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

Function pred_probs

code/lstm.py:406–426  ·  view source on GitHub ↗

If you want to use a trained model, this is useful to compute the probabilities of new examples.

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

Source from the content-addressed store, hash-verified

404
405
406def pred_probs(f_pred_prob, prepare_data, data, iterator, verbose=False):
407 """ If you want to use a trained model, this is useful to compute
408 the probabilities of new examples.
409 """
410 n_samples = len(data[0])
411 probs = numpy.zeros((n_samples, 2)).astype(config.floatX)
412
413 n_done = 0
414
415 for _, valid_index in iterator:
416 x, mask, y = prepare_data([data[0][t] for t in valid_index],
417 numpy.array(data[1])[valid_index],
418 maxlen=None)
419 pred_probs = f_pred_prob(x, mask)
420 probs[valid_index, :] = pred_probs
421
422 n_done += len(valid_index)
423 if verbose:
424 print('%d/%d samples classified' % (n_done, n_samples))
425
426 return probs
427
428
429def pred_error(f_pred, prepare_data, data, iterator, verbose=False):

Callers

nothing calls this directly

Calls 1

prepare_dataFunction · 0.85

Tested by

no test coverage detected