(model, input, target, stats_dir, probs_dir, iteration)
Evaluate a model.

    Args:
      model: object
      output: 2d array, (samples_num, classes_num)
      target: 2d array, (samples_num, classes_num)
      stats_dir: str, directory to write out statistics.
      probs_dir: str, directory to write out output (samples_num, classes_num)
      iteration: int

    Returns:
      None
Evaluate a model.
Evaluate a model .
def evaluate(model, input, target, stats_dir, probs_dir, iteration):
    """Evaluate a model.

    Args:
      model: object
      output: 2d array, (samples_num, classes_num)
      target: 2d array, (samples_num, classes_num)
      stats_dir: str, directory to write out statistics.
      probs_dir: str, directory to write out output (samples_num, classes_num)
      iteration: int

    Returns:
      None
    """

    utilities.create_folder(stats_dir)
    utilities.create_folder(probs_dir)

    # Predict presence probabilittarget
    callback_time = time.time()
    (clips_num, time_steps, freq_bins) = input.shape
    (input, target) = utilities.transform_data(input, target)
    output = model.predict(input)
    output = output.astype(np.float32)  # (clips_num, classes_num)

    # Write out presence probabilities
    prob_path = os.path.join(probs_dir, "prob_{}_iters.p".format(iteration))
    cPickle.dump(output, open(prob_path, 'wb'))

    # Calculate statistics
    stats = utilities.calculate_stats(output, target)

    # Write out statistics
    stat_path = os.path.join(stats_dir, "stat_{}_iters.p".format(iteration))
    cPickle.dump(stats, open(stat_path, 'wb'))

    mAP = np.mean([stat['AP'] for stat in stats])
    mAUC = np.mean([stat['auc'] for stat in stats])
    logging.info(
        "mAP: {:.6f}, AUC: {:.6f}, Callback time: {:.3f} s".format(
            mAP, mAUC, time.time() - callback_time))

    if False:
        logging.info("Saveing prob to {}".format(prob_path))
        logging.info("Saveing stat to {}".format(stat_path))
def evaluate ( model , input , target , stats_dir , probs_dir , iteration ) : utilities . create_folder ( stats_dir ) utilities . create_folder ( probs_dir ) # Predict presence probabilittarget callback_time = time . time ( ) ( clips_num , time_steps , freq_bins ) = input . shape ( input , target ) = utilities . transform_data ( input , target ) output = model . predict ( input ) output = output . astype ( np . float32 ) # (clips_num, classes_num) # Write out presence probabilities prob_path = os . path . join ( probs_dir , "prob_{}_iters.p" . format ( iteration ) ) cPickle . dump ( output , open ( prob_path , 'wb' ) ) # Calculate statistics stats = utilities . calculate_stats ( output , target ) # Write out statistics stat_path = os . path . join ( stats_dir , "stat_{}_iters.p" . format ( iteration ) ) cPickle . dump ( stats , open ( stat_path , 'wb' ) ) mAP = np . mean ( [ stat [ 'AP' ] for stat in stats ] ) mAUC = np . mean ( [ stat [ 'auc' ] for stat in stats ] ) logging . info ( "mAP: {:.6f}, AUC: {:.6f}, Callback time: {:.3f} s" . format ( mAP , mAUC , time . time ( ) - callback_time ) ) if False : logging . info ( "Saveing prob to {}" . format ( prob_path ) ) logging . info ( "Saveing stat to {}" . format ( stat_path ) )