class_docstr: Trainer for the agreement model.
  
  Attributes:
    model: A Model used to decide if two samples should have the same label.
    is_train: A placeholder for a boolean value specyfing if the model is used
      for train or evaluation.
    data: A CotrainDataset object.
    optimizer: Optimizer used for training the agreement model.
    min_num_iter: An integer representing the minimum number of iterations to
      train the agreement model.
    max_num_iter: An integer representing the maximum number of iterations to
      train the agreement model.
    num_iter_after_best_val: An integer representing the number of extra
      iterations to perform after improving the validation set accuracy.
    max_num_iter_cotrain: An integer representing the maximum number of cotrain
      iterations to train for.
    num_warm_up_iter: The agreement model will return 0 for the first
      `num_warm_up_iter` co-training iterations.
    batch_size: Batch size for used when training and evaluating the agreement
      model.
    gradient_clip: A float number representing the maximum gradient norm allowed
      if we do gradient clipping. If None, no gradient clipping is performed.
    enable_summaries: Boolean specifying whether to enable variable summaries.
    summary_step: Integer representing the summary step size.
    summary_dir: String representing the path to a directory where to save the
      variable summaries.
    logging_step: Integer representing the number of iterations after which we
      log the loss of the model.
    eval_step: Integer representing the number of iterations after which we
      evaluate the model.
    abs_loss_chg_tol: A float representing the absolute tolerance for checking
      if the training loss has converged. If the difference between the current
      loss and previous loss is less than `abs_loss_chg_tol`, we count this
      iteration towards convergence (see `loss_chg_iter_below_tol`).
    rel_loss_chg_tol: A float representing the relative tolerance for checking
      if the training loss has converged. If the ratio between the current loss
      and previous loss is less than `rel_loss_chg_tol`, we count this iteration
      towards convergence (see `loss_chg_iter_below_tol`).
    loss_chg_iter_below_tol: An integer representing the number of consecutive
      iterations that pass the convergence criteria before stopping training.
    warm_start: Whether the agreement model parameters are initialized at their
      best value in the previous cotrain iteration. If False, they are
      reinitialized.
    checkpoints_dir: Path to the folder where to store TensorFlow model
      checkpoints.
    weight_decay: Weight decay value.
    weight_decay_schedule: Schedule for the weight decay variable.
    num_pairs_eval_random: Integer representing the number of pairs to use for
      evaluation. These pairs are randomly drawn from all datasets, including
      validation and test. This is only used for monitoring the performance, but
      is not involved in training the agreement model.
    agree_by_default: Boolean specifying whether to return agreement by default
      or disagreement by default when the agreement model is not warmed up.
    percent_val: Ratio of samples to use for validation.
    max_num_samples_val: Maximum number of samples to include in the validation
      set.
    seed: Integer representing the seed for the random number generator.
    use_graph: Boolean specifying whether to use the graph edges, or any pair of
      samples.
    add_negative_edges: Boolean specifying whether to add fake negative edges
      when training the agreement model, in order to keep the classes balanced.
      Only applies when `use_graph` is True.
class_docstr_tok: ["Trainer","for","the","agreement","model",".","Attributes",":","model",":","A","Model","used","to","decide","if","two","samples","should","have","the","same","label",".","is_train",":","A","placeholder","for","a","boolean","value","specyfing","if","the","model","is","used","for","train","or","evaluation",".","data",":","A","CotrainDataset","object",".","optimizer",":","Optimizer","used","for","training","the","agreement","model",".","min_num_iter",":","An","integer","representing","the","minimum","number","of","iterations","to","train","the","agreement","model",".","max_num_iter",":","An","integer","representing","the","maximum","number","of","iterations","to","train","the","agreement","model",".","num_iter_after_best_val",":","An","integer","representing","the","number","of","extra","iterations","to","perform","after","improving","the","validation","set","accuracy",".","max_num_iter_cotrain",":","An","integer","representing","the","maximum","number","of","cotrain","iterations","to","train","for",".","num_warm_up_iter",":","The","agreement","model","will","return","0","for","the","first","`","num_warm_up_iter","`","co-training","iterations",".","batch_size",":","Batch","size","for","used","when","training","and","evaluating","the","agreement","model",".","gradient_clip",":","A","float","number","representing","the","maximum","gradient","norm","allowed","if","we","do","gradient","clipping",".","If","None",",","no","gradient","clipping","is","performed",".","enable_summaries",":","Boolean","specifying","whether","to","enable","variable","summaries",".","summary_step",":","Integer","representing","the","summary","step","size",".","summary_dir",":","String","representing","the","path","to","a","directory","where","to","save","the","variable","summaries",".","logging_step",":","Integer","representing","the","number","of","iterations","after","which","we","log","the","loss","of","the","model",".","eval_step",":","Integer","representing","the","number","of","iterations","after","which","we","evaluate","the","model",".","abs_loss_chg_tol",":","A","float","representing","the","absolute","tolerance","for","checking","if","the","training","loss","has","converged",".","If","the","difference","between","the","current","loss","and","previous","loss","is","less","than","`","abs_loss_chg_tol","`",",","we","count","this","iteration","towards","convergence","(","see","`","loss_chg_iter_below_tol","`",")",".","rel_loss_chg_tol",":","A","float","representing","the","relative","tolerance","for","checking","if","the","training","loss","has","converged",".","If","the","ratio","between","the","current","loss","and","previous","loss","is","less","than","`","rel_loss_chg_tol","`",",","we","count","this","iteration","towards","convergence","(","see","`","loss_chg_iter_below_tol","`",")",".","loss_chg_iter_below_tol",":","An","integer","representing","the","number","of","consecutive","iterations","that","pass","the","convergence","criteria","before","stopping","training",".","warm_start",":","Whether","the","agreement","model","parameters","are","initialized","at","their","best","value","in","the","previous","cotrain","iteration",".","If","False",",","they","are","reinitialized",".","checkpoints_dir",":","Path","to","the","folder","where","to","store","TensorFlow","model","checkpoints",".","weight_decay",":","Weight","decay","value",".","weight_decay_schedule",":","Schedule","for","the","weight","decay","variable",".","num_pairs_eval_random",":","Integer","representing","the","number","of","pairs","to","use","for","evaluation",".","These","pairs","are","randomly","drawn","from","all","datasets",",","including","validation","and","test",".","This","is","only","used","for","monitoring","the","performance",",","but","is","not","involved","in","training","the","agreement","model",".","agree_by_default",":","Boolean","specifying","whether","to","return","agreement","by","default","or","disagreement","by","default","when","the","agreement","model","is","not","warmed","up",".","percent_val",":","Ratio","of","samples","to","use","for","validation",".","max_num_samples_val",":","Maximum","number","of","samples","to","include","in","the","validation","set",".","seed",":","Integer","representing","the","seed","for","the","random","number","generator",".","use_graph",":","Boolean","specifying","whether","to","use","the","graph","edges",",","or","any","pair","of","samples",".","add_negative_edges",":","Boolean","specifying","whether","to","add","fake","negative","edges","when","training","the","agreement","model",",","in","order","to","keep","the","classes","balanced",".","Only","applies","when","`","use_graph","`","is","True","."]
docstr: Collects edges between labeled nodes, used to train the agreement model.
  
  Args:
    data: A SSLDataset object.
  
  Returns:
    A tuple containing (edges_train, agreement_train, edges_val,
    agreement_val) containing the edges used for training, the agreement
    between the train labels, the edges used for validation, and the
    agreement between the validation labels.
code: def _get_neighbors(self, data):
      """Collects edges between labeled nodes, used to train the agreement model.
  
      Args:
        data: A SSLDataset object.
  
      Returns:
        A tuple containing (edges_train, agreement_train, edges_val,
        agreement_val) containing the edges used for training, the agreement
        between the train labels, the edges used for validation, and the
        agreement between the validation labels.
      """
      edges = data.get_edges(src_labeled=True, tgt_labeled=True)
  
      if not edges:
          empty_edges = np.zeros(shape=(0, 2), dtype=np.int32)
          empty_agreement = np.zeros(shape=(0,), dtype=np.float32)
          return (
              empty_edges,
              empty_agreement,
              empty_edges,
              empty_agreement,
          )
  
      edges = np.stack([(e.src, e.tgt) for e in edges])
      agreement = np.equal(
          data.get_labels(edges[:, 0]), data.get_labels(edges[:, 1])
      )
  
      # Select validation set for agreement.
      train_ind, val_ind = split_train_val(
          np.arange(agreement.shape[0]),
          self.ratio_val,
          self.rng,
          max_num_val=self.max_num_samples_val,
      )
  
      return (
          edges[train_ind],
          agreement[train_ind],
          edges[val_ind],
          agreement[val_ind],
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import logging
  import os
  from ..data.preprocessing import split_train_val
  import numpy
  import tensorflow
  from .trainer_base import batch_iterator
  from .trainer_base import Trainer
label_desc: Use image node_id 16 for calling the TrainerAgreement obj's underlying member method code with example usage: obj._get_neighbors(data) and returns: edges,  agreement,  edges,  agreement, empty_edges,  empty_agreement,  empty_edges,  empty_agreement