File size: 3,396 Bytes
a9d9f4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[
  {
    "function_name": "WTTM.__init__",
    "file_path": "TTM/distiller_zoo/wttm.py",
    "function_calls": [
      {
        "function_call_name": "super",
        "functionality": "Returns a proxy object that delegates method calls to a parent or sibling class. Used to call methods of a parent class in a child class's method.",
        "input": "",
        "output": "A super object that represents the parent class.",
        "location_or_namespace": "built-in"
      },
      {
        "function_call_name": "__init__",
        "functionality": "Initializes the nn.Module parent class.",
        "input": "",
        "output": "None",
        "location_or_namespace": "torch.nn.Module"
      }
    ]
  },
  {
    "function_name": "WTTM.forward",
    "file_path": "TTM/distiller_zoo/wttm.py",
    "function_calls": [
      {
        "function_call_name": "log_softmax",
        "functionality": "Applies a softmax function followed by a logarithm. Used to convert logits into log-probabilities for the student's output (p_s).",
        "input": "y_s (Tensor), dim=1 (int)",
        "output": "p_s (Tensor)",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "softmax",
        "functionality": "Applies a softmax function to the teacher's logits to convert them into a probability distribution.",
        "input": "y_t (Tensor), dim=1 (int)",
        "output": "Teacher probabilities (Tensor)",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "pow",
        "functionality": "Raises each element in the input tensor to the power of the exponent. Used here to apply the power transform to the teacher's probabilities.",
        "input": "base (Tensor), exponent (float)",
        "output": "p_t (Tensor)",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "sum",
        "functionality": "Calculates the sum of all elements in the input tensor along a specified dimension. Used to compute the normalization term for the power-transformed teacher probabilities.",
        "input": "input (Tensor), dim=1 (int)",
        "output": "norm (Tensor)",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "unsqueeze",
        "functionality": "Returns a new tensor with a dimension of size one inserted at the specified position. Used to make 'norm' broadcastable for element-wise division.",
        "input": "dim (int)",
        "output": "Reshaped norm (Tensor)",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "kl_div",
        "functionality": "Computes the Kullback-Leibler divergence between two probability distributions. Used here to calculate the KL divergence between student and transformed teacher probabilities.",
        "input": "input (Tensor), target (Tensor), reduction='none' (str)",
        "output": "Element-wise KL divergence (Tensor)",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "mean",
        "functionality": "Calculates the mean value of all elements in the input tensor. Used to average the weighted KL divergence over the batch to get the final loss.",
        "input": "input (Tensor)",
        "output": "loss (Tensor)",
        "location_or_namespace": "torch"
      }
    ]
  }
]