nodes: 0, module; 1, function_definition; 2, function_name:optimize_with_repeates; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, expression_statement; 14, if_statement; 15, expression_statement; 16, expression_statement; 17, comment:# minimize n_times; 18, for_statement; 19, comment:# sort by LML; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, if_statement; 24, for_statement; 25, return_statement; 26, identifier:fast; 27, None; 28, identifier:verbose; 29, None; 30, identifier:n_times; 31, integer:10; 32, identifier:lambd; 33, None; 34, identifier:lambd_g; 35, None; 36, identifier:lambd_n; 37, None; 38, comment:"""
          Train the model repeadly up to a number specified by the users with random restarts and
          return a list of all relative minima that have been found. This list is sorted according to
          least likelihood. Each list term is a dictionary with keys "counter", "LML", and "scales".
  
          After running this function, the vc object will be set at the last iteration. Thus, if you
          wish to get the vc object of one of the repeats, then set the scales. For example:
  
          vc.setScales(scales=optimize_with_repeates_output[0]["scales"])
  
          Args:
              fast:       Boolean. if set to True initalize kronSumGP
              verbose:    Boolean. If set to True, verbose output is produced. (default True)
              n_times:    number of re-starts of the optimization. (default 10)
          """; 39, assignment; 40, not_operator; 41, block; 42, assignment; 43, assignment; 44, identifier:i; 45, call; 46, block; 47, assignment; 48, assignment; 49, assignment; 50, identifier:verbose; 51, block; 52, identifier:i; 53, call; 54, block; 55, identifier:out; 56, identifier:verbose; 57, call; 58, attribute; 59, expression_statement; 60, identifier:opt_list; 61, list; 62, identifier:fixed0; 63, call; 64, identifier:range; 65, argument_list; 66, expression_statement; 67, expression_statement; 68, expression_statement; 69, if_statement; 70, identifier:LML; 71, call; 72, identifier:index; 73, subscript; 74, identifier:out; 75, list; 76, expression_statement; 77, expression_statement; 78, expression_statement; 79, identifier:range; 80, argument_list; 81, expression_statement; 82, if_statement; 83, attribute; 84, argument_list; 85, identifier:self; 86, identifier:init; 87, call; 88, attribute; 89, argument_list; 90, identifier:n_times; 91, assignment; 92, assignment; 93, assignment; 94, identifier:conv; 95, comment:# compare with previous minima; 96, block; 97, attribute; 98, argument_list; 99, call; 100, slice; 101, call; 102, call; 103, call; 104, call; 105, call; 106, identifier:verbose; 107, block; 108, identifier:dlimix; 109, identifier:getVerbose; 110, identifier:verbose; 111, attribute; 112, argument_list; 113, identifier:sp; 114, identifier:zeros_like; 115, subscript; 116, identifier:scales1; 117, call; 118, identifier:fixed1; 119, binary_operator:1e-1*sp.randn(fixed0.shape[0],fixed0.shape[1]); 120, identifier:conv; 121, call; 122, expression_statement; 123, for_statement; 124, if_statement; 125, identifier:sp; 126, identifier:array; 127, list_comprehension; 128, attribute; 129, argument_list; 130, unary_operator; 131, identifier:print; 132, argument_list; 133, identifier:print; 134, argument_list; 135, identifier:print; 136, argument_list; 137, identifier:len; 138, argument_list; 139, attribute; 140, argument_list; 141, expression_statement; 142, expression_statement; 143, identifier:self; 144, identifier:_initGP; 145, identifier:fast; 146, call; 147, string; 148, attribute; 149, argument_list; 150, float:1e-1; 151, call; 152, attribute; 153, argument_list; 154, assignment; 155, identifier:j; 156, call; 157, block; 158, comparison_operator:temp==1; 159, block; 160, subscript; 161, for_in_clause; 162, identifier:LML; 163, identifier:argsort; 164, integer:1; 165, string:"\nLocal mimima\n"; 166, string:"n_times\t\tLML"; 167, string:"------------------------------------"; 168, identifier:opt_list; 169, identifier:out; 170, identifier:append; 171, subscript; 172, call; 173, call; 174, attribute; 175, argument_list; 176, string_content:dataTerm; 177, identifier:self; 178, identifier:_getScalesRand; 179, attribute; 180, argument_list; 181, identifier:self; 182, identifier:trainGP; 183, keyword_argument; 184, keyword_argument; 185, keyword_argument; 186, keyword_argument; 187, keyword_argument; 188, keyword_argument; 189, identifier:temp; 190, integer:1; 191, identifier:range; 192, argument_list; 193, if_statement; 194, identifier:temp; 195, integer:1; 196, expression_statement; 197, expression_statement; 198, expression_statement; 199, expression_statement; 200, expression_statement; 201, subscript; 202, string; 203, identifier:i; 204, call; 205, identifier:opt_list; 206, subscript; 207, identifier:print; 208, argument_list; 209, identifier:print; 210, argument_list; 211, attribute; 212, identifier:getParams; 213, identifier:sp; 214, identifier:randn; 215, subscript; 216, subscript; 217, identifier:fast; 218, identifier:fast; 219, identifier:scales0; 220, identifier:scales1; 221, identifier:fixed0; 222, identifier:fixed1; 223, identifier:lambd; 224, identifier:lambd; 225, identifier:lambd_g; 226, identifier:lambd_g; 227, identifier:lambd_n; 228, identifier:lambd_n; 229, call; 230, call; 231, block; 232, assignment; 233, assignment; 234, assignment; 235, assignment; 236, call; 237, identifier:opt_list; 238, identifier:i; 239, string_content:LML; 240, identifier:range; 241, argument_list; 242, identifier:index; 243, identifier:i; 244, parenthesized_expression; 245, string:""; 246, identifier:self; 247, identifier:gp; 248, attribute; 249, integer:0; 250, attribute; 251, integer:1; 252, identifier:len; 253, argument_list; 254, attribute; 255, argument_list; 256, expression_statement; 257, expression_statement; 258, break_statement; 259, identifier:opt; 260, dictionary; 261, subscript; 262, integer:1; 263, subscript; 264, call; 265, subscript; 266, call; 267, attribute; 268, argument_list; 269, call; 270, binary_operator:"%d\t\t%f" % (opt_list[index[i]]['counter'], opt_list[index[i]]['LML']); 271, identifier:fixed0; 272, identifier:shape; 273, identifier:fixed0; 274, identifier:shape; 275, identifier:opt_list; 276, identifier:sp; 277, identifier:allclose; 278, call; 279, call; 280, assignment; 281, augmented_assignment; 282, identifier:opt; 283, string; 284, identifier:opt; 285, string; 286, attribute; 287, argument_list; 288, identifier:opt; 289, string; 290, attribute; 291, argument_list; 292, identifier:opt_list; 293, identifier:append; 294, identifier:opt; 295, identifier:len; 296, argument_list; 297, string:"%d\t\t%f"; 298, tuple; 299, identifier:abs; 300, argument_list; 301, identifier:abs; 302, argument_list; 303, identifier:temp; 304, integer:0; 305, subscript; 306, integer:1; 307, string_content:counter; 308, string_content:LML; 309, identifier:self; 310, identifier:getLML; 311, string_content:scales; 312, identifier:self; 313, identifier:getScales; 314, identifier:opt_list; 315, subscript; 316, subscript; 317, call; 318, subscript; 319, subscript; 320, string; 321, subscript; 322, string; 323, subscript; 324, string; 325, attribute; 326, argument_list; 327, subscript; 328, string; 329, identifier:opt_list; 330, identifier:j; 331, string_content:counter; 332, identifier:opt_list; 333, subscript; 334, string_content:counter; 335, identifier:opt_list; 336, subscript; 337, string_content:LML; 338, identifier:self; 339, identifier:getScales; 340, identifier:opt_list; 341, identifier:j; 342, string_content:scales; 343, identifier:index; 344, identifier:i; 345, identifier:index; 346, identifier:i
code: def optimize_with_repeates(self,fast=None,verbose=None,n_times=10,lambd=None,lambd_g=None,lambd_n=None):
          """
          Train the model repeadly up to a number specified by the users with random restarts and
          return a list of all relative minima that have been found. This list is sorted according to
          least likelihood. Each list term is a dictionary with keys "counter", "LML", and "scales".
  
          After running this function, the vc object will be set at the last iteration. Thus, if you
          wish to get the vc object of one of the repeats, then set the scales. For example:
  
          vc.setScales(scales=optimize_with_repeates_output[0]["scales"])
  
          Args:
              fast:       Boolean. if set to True initalize kronSumGP
              verbose:    Boolean. If set to True, verbose output is produced. (default True)
              n_times:    number of re-starts of the optimization. (default 10)
          """
          verbose = dlimix.getVerbose(verbose)
  
          if not self.init:       self._initGP(fast)
  
          opt_list = []
  
          fixed0 = sp.zeros_like(self.gp.getParams()['dataTerm'])
  
          # minimize n_times
          for i in range(n_times):
  
              scales1 = self._getScalesRand()
              fixed1  = 1e-1*sp.randn(fixed0.shape[0],fixed0.shape[1])
              conv = self.trainGP(fast=fast,scales0=scales1,fixed0=fixed1,lambd=lambd,lambd_g=lambd_g,lambd_n=lambd_n)
  
              if conv:
                  # compare with previous minima
                  temp=1
                  for j in range(len(opt_list)):
                      if sp.allclose(abs(self.getScales()),abs(opt_list[j]['scales'])):
                          temp=0
                          opt_list[j]['counter']+=1
                          break
                  if temp==1:
                      opt = {}
                      opt['counter'] = 1
                      opt['LML'] = self.getLML()
                      opt['scales'] = self.getScales()
                      opt_list.append(opt)
  
  
          # sort by LML
          LML = sp.array([opt_list[i]['LML'] for i in range(len(opt_list))])
          index   = LML.argsort()[::-1]
          out = []
          if verbose:
              print("\nLocal mimima\n")
              print("n_times\t\tLML")
              print("------------------------------------")
  
          for i in range(len(opt_list)):
              out.append(opt_list[index[i]])
              if verbose:
                  print(("%d\t\t%f" % (opt_list[index[i]]['counter'], opt_list[index[i]]['LML'])))
                  print("")
  
          return out