INNER CODE UNIT · Python

model_analysis

haitongli/knowledge-distillation-pytorch · distillation_analysis.py:26

def model_analysis(model, dataloader, params, temperature=1., num_classes=10):
    """
        Generate Confusion Matrix on evaluation set
    """
    model.eval()
    confusion_matrix = ConfusionMeter(num_classes)
    softmax_scores = []
    predict_correct = []

    with tqdm(total=len(dataloader)) as t:
        for idx, (data_batch, labels_batch) in enumerate(dataloader):

            if params.cuda:
                data_batch, labels_batch = data_batch.cuda(async=True), \
                                           labels_batch.cuda(async=True)
            data_batch, labels_batch = Variable(data_batch), Variable(labels_batch)

            output_batch = model(data_batch)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…