class_docstr: Class for evaluating the performance of mapping W
class_docstr_tok: ["Class","for","evaluating","the","performance","of","mapping","W"]
docstr: Get the candidates based on type of dictionary
  Arguments:
       sess(tf.session): Tensorflow session
       dict_type(str): S2T-Source2Target, S2T&T2S (Both)
  Returns:
      Numpy array of max_dict x 2 or smaller
docstr_tok: ["Get","the","candidates","based","on","type","of","dictionary","Arguments",":","sess","(","tf.session",")",":","Tensorflow","session","dict_type","(","str",")",":","S2T-Source2Target",",","S2T","&","T2S","(","Both",")","Returns",":","Numpy","array","of","max_dict","x","2","or","smaller"]
code: def get_candidates(
      self, sess, avg1, avg2, batch_size=512, swap_score=False
  ):
      """
      Get the candidates based on type of dictionary
      Arguments:
           sess(tf.session): Tensorflow session
           dict_type(str): S2T-Source2Target, S2T&T2S (Both)
      Returns:
          Numpy array of max_dict x 2 or smaller
      """
      all_scores = []
      all_targets = []
      for i in range(0, self.max_dict_size, batch_size):
          src_ids = [
              x
              for x in range(i, min(i + batch_size, self.max_dict_size))
          ]
          dict_dict = {self.src_ph: src_ids, self.tgt_ph: self.tgt_ids}
          if swap_score:
              temp_score = sess.run(
                  self.csls_subgraphs["ScoreG_T2S"], feed_dict=dict_dict
              )
          else:
              temp_score = sess.run(
                  self.csls_subgraphs["ScoreGraph"], feed_dict=dict_dict
              )
          batch_score = 2 * temp_score - (
              avg1[src_ids][:, None] + avg2[None, :]
          )
          top_matches = sess.run(
              self.csls_subgraphs["Top2"],
              feed_dict={self.score_ph: batch_score},
          )
          all_scores.append(top_matches[0])
          all_targets.append(top_matches[1])
      all_scores = np.concatenate(all_scores)
      all_targets = np.concatenate(all_targets)
      all_pairs = np.concatenate(
          [
              np.arange(0, self.max_dict_size, dtype=np.int64)[:, None],
              all_targets[:, 0][:, None],
          ],
          1,
      )
  
      # Scores with high confidence will have large difference between first two guesses
      diff = all_scores[:, 0] - all_scores[:, 1]
      reordered = np.argsort(diff, axis=0)
      reordered = reordered[::-1]
      all_pairs = all_pairs[reordered]
  
      # Select words which are in top max_dict
      selected = np.max(all_pairs, axis=1) <= self.max_dict_size
      all_pairs = all_pairs[selected]
  
      # Make sure size is less than max_dict
      all_pairs = all_pairs[: self.max_dict_size]
      return all_pairs
  
file_path: nlp-architect/examples/crosslingembs/evaluate.py
imports: from __future__ import print_function, division
  import numpy
  import tensorflow
  from nlp_architect.data.fasttext_emb import get_eval_data
label_desc: Use image node_id 13 for calling the Evaluate obj's underlying member method code with example usage: obj.get_candidates(sess, avg1, avg2, batch_size, swap_score) and returns: all_pairs