class_docstr: Test case for package-level functions for correctness.
class_docstr_tok: ["Test","case","for","package-level","functions","for","correctness","."]
docstr: Check that reference and unpatched target net have equal weights.
  
  This is mostly a sanity check for the purpose of the other unit tests.
docstr_tok: ["Check","that","reference","and","unpatched","target","net","have","equal","weights",".","This","is","mostly","a","sanity","check","for","the","purpose","of","the","other","unit","tests","."]
code: def testSameInitialWeightsPrePatch(self):
      """Check that reference and unpatched target net have equal weights.
  
      This is mostly a sanity check for the purpose of the other unit tests.
      """
      ref_params = list(self.reference_net.named_parameters())
      target_params = list(self.target_net.named_parameters())
      self.assertEqual(
          len(ref_params),
          len(target_params),
          msg=(
              "Length mismatched between reference net parameter count "
              "({}) and target ({}).".format(
                  len(ref_params), len(target_params)
              )
          ),
      )
      for ref, target in zip(ref_params, target_params):
          ref_name, ref_p = ref
          target_name, target_p = target
          self.assertEqual(
              ref_name,
              target_name,
              msg="Name mismatch or parameter misalignment ('{}' vs '{}')".format(
                  ref_name, target_name
              ),
          )
          self.assertTrue(
              torch.equal(ref_p, target_p),
              msg="Parameter value inequality for {}".format(ref_name),
          )
  
imports: import unittest
  import copy
  from collections import OrderedDict
  import numpy
  import torch
  from torch import nn, optim
  from torch.nn import functional
  import higher
label_desc: Use image node_id 2 for calling the TestCorrectness obj's underlying member method code with example usage: obj.testSameInitialWeightsPrePatch() without return types