Returns weights from registered layers. Returns: weights (Python dictionary): a dictionary of the pair {layer_name: weight}, where weight is the weight tensor.
(self)
| 234 | return activation_dict, preds |
| 235 | |
| 236 | def get_weights(self): |
| 237 | """ |
| 238 | Returns weights from registered layers. |
| 239 | Returns: |
| 240 | weights (Python dictionary): a dictionary of the pair |
| 241 | {layer_name: weight}, where weight is the weight tensor. |
| 242 | """ |
| 243 | weights = {} |
| 244 | for layer in self.layers_names: |
| 245 | cur_layer = get_layer(self.model, layer) |
| 246 | if hasattr(cur_layer, "weight"): |
| 247 | weights[layer] = cur_layer.weight.clone().detach() |
| 248 | else: |
| 249 | logger.error( |
| 250 | "Layer {} does not have weight attribute.".format(layer) |
| 251 | ) |
| 252 | return weights |
| 253 | |
| 254 | |
| 255 | def get_indexing(string): |
no test coverage detected