R/losses.R

Defines functions error_rate

Documented in error_rate

#' @title Error rate
#'
#' @description 1 - `accuracy`
#'
#' @param inp The predictions of the model
#' @param targ The corresponding labels
#' @param axis Axis
#' @return tensor
#'
#' @examples
#'
#' \dontrun{
#'
#' learn = cnn_learner(dls, resnet34(), metrics = error_rate)
#'
#'
#' }
#'
#'
#' @export
error_rate <- function(inp, targ, axis = -1) {

  if(missing(inp) & missing(targ)) {
    vision()$all$error_rate
  } else {
    args <- list(
      inp = inp,
      targ = targ,
      axis = as.integer(axis)
    )

    do.call(vision()$all$error_rate, args)
  }

}

attr(error_rate ,"py_function_name") <- "error_rate"

Try the fastai package in your browser

Any scripts or data that you put into this service are public.

fastai documentation built on March 31, 2023, 11:41 p.m.