def pred_error(f_pred, prepare_data, data, iterator, verbose=False):
 valid_err = 0
 for (_, valid_index) in iterator:
  (x, mask, y) = prepare_data([data[0][t] for t in valid_index], numpy.array(data[1])[valid_index], maxlen=None)
  preds = f_pred(x, mask)
  targets = numpy.array(data[1])[valid_index]
  valid_err += (preds == targets).sum()
 valid_err = (1.0 - (numpy_floatX(valid_err) / len(data[0])))
 return valid_err

def pred_error ( f_pred , prepare_data , data , iterator , verbose = False ) : valid_err = 0 for ( _ , valid_index ) in iterator : ( x , mask , y ) = prepare_data ( [ data [ 0 ] [ t ] for t in valid_index ] , numpy . array ( data [ 1 ] ) [ valid_index ] , maxlen = None ) preds = f_pred ( x , mask ) targets = numpy . array ( data [ 1 ] ) [ valid_index ] valid_err += ( preds == targets ) . sum ( ) valid_err = ( 1.0 - ( numpy_floatX ( valid_err ) / len ( data [ 0 ] ) ) ) return valid_err
just compute the error f_pred: theano fct computing the prediction prepare_data: usual prepare_data for that dataset .