def batch_iterator_valid(data_test, y_test, batchsize, valid_fn):
 n_samples_valid = data_test.shape[0]
 loss_valid = []
 acc_valid = []
 for i in range((((n_samples_valid + batchsize) - 1) // batchsize)):
  sl = slice((i * batchsize), ((i + 1) * batchsize))
  X_batch_test = data_test[sl]
  y_batch_test = y_test[sl]
  (loss_vv, acc_vv) = valid_fn(X_batch_test, y_batch_test)
  loss_valid.append(loss_vv)
  acc_valid.append(acc_vv)
 return (np.mean(loss_valid), np.mean(acc_valid))

def batch_iterator_valid ( data_test , y_test , batchsize , valid_fn ) : n_samples_valid = data_test . shape [ 0 ] loss_valid = [ ] acc_valid = [ ] for i in range ( ( ( ( n_samples_valid + batchsize ) - 1 ) // batchsize ) ) : sl = slice ( ( i * batchsize ) , ( ( i + 1 ) * batchsize ) ) X_batch_test = data_test [ sl ] y_batch_test = y_test [ sl ] ( loss_vv , acc_vv ) = valid_fn ( X_batch_test , y_batch_test ) loss_valid . append ( loss_vv ) acc_valid . append ( acc_vv ) return ( np . mean ( loss_valid ) , np . mean ( acc_valid ) )
batch iterator for fine tuning network .