File size: 6,606 Bytes
f2cf608 | 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | [
{
"function_name": "collect_grads",
"file_path": "collect_grad_reps.py",
"function_calls": [
{
"function_call_name": "torch.random.manual_seed",
"functionality": "Sets the seed for generating random numbers in PyTorch for reproducibility.",
"input": "seed (int)",
"output": "None",
"location_or_namespace": "torch"
},
{
"function_call_name": "torch.stack",
"functionality": "Concatenates a sequence of tensors along a new dimension.",
"input": "sequence of tensors",
"output": "stacked tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "to",
"functionality": "Casts a tensor to the specified type/device.",
"input": "dtype, device, or both",
"output": "converted tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "projector.project",
"functionality": "Projects the input gradient tensor into a lower-dimensional subspace using a random projection matrix.",
"input": "gradient tensor, model_id (int)",
"output": "projected gradient tensor",
"location_or_namespace": "trak.projectors.BasicProjector or CudaProjector"
},
{
"function_call_name": "cpu",
"functionality": "Moves a tensor to CPU memory.",
"input": "None",
"output": "tensor on CPU",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "torch.cat",
"functionality": "Concatenates a sequence of tensors along an existing dimension.",
"input": "sequence of tensors",
"output": "concatenated tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "os.path.join",
"functionality": "Joins one or more path components intelligently.",
"input": "directory path(s), file name(s)",
"output": "joined path string",
"location_or_namespace": "os"
},
{
"function_call_name": "torch.save",
"functionality": "Saves an object to a disk file.",
"input": "object, file path",
"output": "None",
"location_or_namespace": "torch"
},
{
"function_call_name": "print",
"functionality": "Prints the given object(s) to the console or standard output.",
"input": "object(s), optional flush parameter",
"output": "None",
"location_or_namespace": "builtins"
},
{
"function_call_name": "next",
"functionality": "Retrieves the next item from an iterator.",
"input": "iterator",
"output": "next item from iterator",
"location_or_namespace": "builtins"
},
{
"function_call_name": "model.parameters",
"functionality": "Returns an iterator over model parameters.",
"input": "None",
"output": "iterator over parameters",
"location_or_namespace": "torch.nn.Module"
},
{
"function_call_name": "assert",
"functionality": "Raises an AssertionError if the condition is false.",
"input": "condition",
"output": "None or exception",
"location_or_namespace": "builtins"
},
{
"function_call_name": "prepare_optimizer_state",
"functionality": "",
"input": "model, adam_optimizer_state, device",
"output": "m, v (momentum statistics)",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "get_trak_projector",
"functionality": "",
"input": "device",
"output": "projector class/factory",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "get_number_of_params",
"functionality": "",
"input": "model",
"output": "number of parameters (int)",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "os.makedirs",
"functionality": "Creates a directory recursively; does not raise an error if directory exists.",
"input": "directory path, exist_ok (bool)",
"output": "None",
"location_or_namespace": "os"
},
{
"function_call_name": "get_max_saved_index",
"functionality": "",
"input": "output_dir, prefix",
"output": "max index (int)",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "tqdm",
"functionality": "Wraps an iterable with a progress bar for iteration.",
"input": "iterable, total",
"output": "iterator with progress bar",
"location_or_namespace": "tqdm"
},
{
"function_call_name": "prepare_batch",
"functionality": "",
"input": "batch",
"output": "",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "obtain_gradients_with_adam",
"functionality": "",
"input": "model, batch, m, v",
"output": "gradient vector",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "obtain_sign_gradients",
"functionality": "",
"input": "model, batch",
"output": "gradient vector",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "obtain_gradients",
"functionality": "",
"input": "model, batch",
"output": "gradient vector",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "model.zero_grad",
"functionality": "Sets gradients of all model parameters to zero.",
"input": "None",
"output": "None",
"location_or_namespace": "torch.nn.Module"
},
{
"function_call_name": "torch.cuda.empty_cache",
"functionality": "Releases all unused cached memory from CUDA.",
"input": "None",
"output": "None",
"location_or_namespace": "torch.cuda"
},
{
"function_call_name": "merge_and_normalize_info",
"functionality": "",
"input": "output_dir, prefix",
"output": "",
"location_or_namespace": "collect_grad_reps.py"
},
{
"function_call_name": "merge_info",
"functionality": "",
"input": "output_dir, prefix",
"output": "",
"location_or_namespace": "collect_grad_reps.py"
}
]
}
]
|