def computeStatsEigen(self):
<EOL>with tf.device('<STR_LIT>'):<EOL><INDENT>def removeNone(tensor_list):<EOL><INDENT>local_list = []<EOL>for item in tensor_list:<EOL><INDENT>if item is not None:<EOL><INDENT>local_list.append(item)<EOL><DEDENT><DEDENT>return local_list<EOL><DEDENT>def copyStats(var_list):<EOL><INDENT>print("<STR_LIT>")<EOL>redundant_stats = {}<EOL>copied_list = []<EOL>for item in var_list:<EOL><INDENT>if item is not None:<EOL><INDENT>if item not in redundant_stats:<EOL><INDENT>if self._use_float64:<EOL><INDENT>redundant_stats[item] = tf.cast(<EOL>tf.identity(item), tf.float64)<EOL><DEDENT>else:<EOL><INDENT>redundant_stats[item] = tf.identity(item)<EOL><DEDENT><DEDENT>copied_list.append(redundant_stats[item])<EOL><DEDENT>else:<EOL><INDENT>copied_list.append(None)<EOL><DEDENT><DEDENT>return copied_list<EOL><DEDENT>stats_eigen = self.stats_eigen<EOL>computedEigen = {}<EOL>eigen_reverse_lookup = {}<EOL>updateOps = []<EOL>with tf.control_dependencies([]):<EOL><INDENT>for stats_var in stats_eigen:<EOL><INDENT>if stats_var not in computedEigen:<EOL><INDENT>eigens = tf.self_adjoint_eig(stats_var)<EOL>e = eigens[<NUM_LIT:0>]<EOL>Q = eigens[<NUM_LIT:1>]<EOL>if self._use_float64:<EOL><INDENT>e = tf.cast(e, tf.float32)<EOL>Q = tf.cast(Q, tf.float32)<EOL><DEDENT>updateOps.append(e)<EOL>updateOps.append(Q)<EOL>computedEigen[stats_var] = {'<STR_LIT:e>': e, '<STR_LIT>': Q}<EOL>eigen_reverse_lookup[e] = stats_eigen[stats_var]['<STR_LIT:e>']<EOL>eigen_reverse_lookup[Q] = stats_eigen[stats_var]['<STR_LIT>']<EOL><DEDENT><DEDENT><DEDENT>self.eigen_reverse_lookup = eigen_reverse_lookup<EOL>self.eigen_update_list = updateOps<EOL>if KFAC_DEBUG:<EOL><INDENT>self.eigen_update_list = [item for item in updateOps]<EOL>with tf.control_dependencies(updateOps):<EOL><INDENT>updateOps.append(tf.Print(tf.constant(<EOL><NUM_LIT:0.>), [tf.convert_to_tensor('<STR_LIT>')]))<EOL><DEDENT><DEDENT><DEDENT>return updateOps<EOL>
compute the eigen decomp using copied var stats to avoid concurrent read/write from other queue