parameters: (self, callback_fn, test_final_params, final_params_numpy,
                             v_ndarray, w_ndarray, x_points, y_points, coefs=None)
return_statement: return paths, z_points
docstring: Compute loss wrapper.
docstring_summary: Compute loss wrapper.
docstring_tokens: Compute loss wrapper .
function: def _cont_loss_wrapper(self, callback_fn, test_final_params, final_params_numpy,
                             v_ndarray, w_ndarray, x_points, y_points, coefs=None):
          """Compute loss wrapper."""
          model, network, valid_dataset, metrics = callback_fn()
          with open(os.path.join(self._ckpt_dir, 'train_metadata.json'), 'r') as file:
              data = json.load(file)
          self._check_json_file_data(data)
          num_samples = data['num_samples']
          batch_size = valid_dataset.get_batch_size()
          num_batches = num_samples // batch_size
          valid_dataset = valid_dataset.take(num_batches)
  
          paths, final_params = [], []
          for (key, value) in test_final_params.items():
              parameter = Parameter(Tensor(value), name=key, requires_grad=True)
              final_params.append(parameter)
          if coefs is not None:
              for i, coef in enumerate(coefs):
                  loss_data = self._cont_loss(valid_dataset, network, model, metrics, final_params,
                                              final_params_numpy, [coef[0]], coef[1], v_ndarray, w_ndarray, path=True)
                  paths.append(loss_data)
                  print("Drawing landscape path total progress is %s/%s, landscape path loss is %s."
                        % (i+1, len(coefs), loss_data[0]))
          # Start to calc loss landscape
          z_points = list()
  
          # Compute loss landscape
          for i, _ in enumerate(y_points):
              print("Drawing landscape total progress: %s/%s." % (i+1, len(y_points)))
              vals = self._cont_loss(valid_dataset, network, model, metrics, final_params,
                                     final_params_numpy, x_points[i], y_points[i][0],
                                     v_ndarray, w_ndarray)
              z_points.append(vals)
  
          return paths, z_points
function_tokens: def _cont_loss_wrapper ( self , callback_fn , test_final_params , final_params_numpy , v_ndarray , w_ndarray , x_points , y_points , coefs = None ) : model , network , valid_dataset , metrics = callback_fn ( ) with open ( os . path . join ( self . _ckpt_dir , 'train_metadata.json' ) , 'r' ) as file : data = json . load ( file ) self . _check_json_file_data ( data ) num_samples = data [ 'num_samples' ] batch_size = valid_dataset . get_batch_size ( ) num_batches = num_samples // batch_size valid_dataset = valid_dataset . take ( num_batches ) paths , final_params = [ ] , [ ] for ( key , value ) in test_final_params . items ( ) : parameter = Parameter ( Tensor ( value ) , name = key , requires_grad = True ) final_params . append ( parameter ) if coefs is not None : for i , coef in enumerate ( coefs ) : loss_data = self . _cont_loss ( valid_dataset , network , model , metrics , final_params , final_params_numpy , [ coef [ 0 ] ] , coef [ 1 ] , v_ndarray , w_ndarray , path = True ) paths . append ( loss_data ) print ( "Drawing landscape path total progress is %s/%s, landscape path loss is %s." % ( i + 1 , len ( coefs ) , loss_data [ 0 ] ) ) # Start to calc loss landscape z_points = list ( ) # Compute loss landscape for i , _ in enumerate ( y_points ) : print ( "Drawing landscape total progress: %s/%s." % ( i + 1 , len ( y_points ) ) ) vals = self . _cont_loss ( valid_dataset , network , model , metrics , final_params , final_params_numpy , x_points [ i ] , y_points [ i ] [ 0 ] , v_ndarray , w_ndarray ) z_points . append ( vals ) return paths , z_points