def accuracy(scores, targets, k):
    """
    Computes top-k accuracy, from predicted and true labels.
    :param scores: scores from the model
    :param targets: true labels
    :param k: k in top-k accuracy
    :return: top-k accuracy
    """

    batch_size = targets.size(0)
    _, ind = scores.topk(k, 1, True, True)
    correct = ind.eq(targets.view(-1, 1).expand_as(ind))
    correct_total = correct.view(-1).float().sum()  # 0D tensor
    return correct_total.item() * (100.0 / batch_size)
  
    
    
    
    
    '''Dataset
The dataset has already been pre-processed and split for you. There are 5000 images and captions for training, 1000 for validation and 1000 for testing. The images, captions, lenght of captions and vocabulary have been saved.

The images have a resolution of (3, 256, 256) (channels, width, height). The captions have a maximum length of 100. Each image has 5 captions and the minimum word frequency is 5.

The functions below facilitate the loading of the dataset.
'''