top_k_accuracy: Top_k_accuracy

Description Usage Arguments Value Examples

View source: R/metric.R

Description

Computes the Top-k accuracy ('targ' is in the top 'k' predictions of 'inp')

Usage

1
top_k_accuracy(inp, targ, k = 5, axis = -1)

Arguments

inp

predictions

targ

targets

k

k

axis

axis

Value

None

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 

loaders = loaders()

data = Data_Loaders(loaders['train'], loaders['valid'])$cuda()

model = nn$Sequential() +
  nn$Flatten() +
  nn$Linear(28L * 28L, 10L)
metrics = list(accuracy,top_k_accuracy)
learn = Learner(data, model, loss_func = F$cross_entropy, opt_func = Adam,
                metrics = metrics)


## End(Not run)

fastai documentation built on July 28, 2021, 5:06 p.m.