(state_dict, layer1_name, layer2_name)
| 45 | return model |
| 46 | |
| 47 | def compare_weights(state_dict, layer1_name, layer2_name): |
| 48 | if layer1_name not in state_dict: |
| 49 | print(f"Layer {layer1_name} not found!") |
| 50 | return False |
| 51 | if layer2_name not in state_dict: |
| 52 | print(f"Layer {layer2_name} not found!") |
| 53 | return False |
| 54 | weight1 = state_dict[layer1_name] |
| 55 | weight2 = state_dict[layer2_name] |
| 56 | |
| 57 | are_equal = torch.equal(weight1, weight2) |
| 58 | if are_equal: |
| 59 | print(f"The weights are identical!") |
| 60 | else: |
| 61 | print(f"The weights are different!") |
| 62 | return are_equal |
nothing calls this directly
no outgoing calls
no test coverage detected