def process_and_load_activations(self, bottleneck_names, concepts):
    acts = {}
    if (self.acts_dir and (not tf.gfile.Exists(self.acts_dir))):
        tf.gfile.MakeDirs(self.acts_dir)
    for concept in concepts:
        if (concept not in acts):
            acts[concept] = {}
        for bottleneck_name in bottleneck_names:
            acts_path = (os.path.join(self.acts_dir, 'acts_{}_{}'.format(concept, bottleneck_name)) if self.acts_dir else None)
            if (acts_path and tf.gfile.Exists(acts_path)):
                with tf.gfile.Open(acts_path, 'rb') as f:
                    acts[concept][bottleneck_name] = np.load(f).squeeze()
                    tf.logging.info('Loaded {} shape {}'.format(acts_path, acts[concept][bottleneck_name].shape))
            else:
                acts[concept][bottleneck_name] = self.get_activations_for_concept(concept, bottleneck_name)
                if acts_path:
                    tf.logging.info('{} does not exist, Making one...'.format(acts_path))
                    with tf.gfile.Open(acts_path, 'w') as f:
                        np.save(f, acts[concept][bottleneck_name], allow_pickle=False)
    return acts
def process_and_load_activations(self, bottleneck_names, concepts):
    acts = {}
    if (self.acts_dir and (not tf.gfile.Exists(self.acts_dir))):
        tf.gfile.MakeDirs(self.acts_dir)
    for concept in concepts:
        if (concept not in acts):
            acts[concept] = {}
        for bottleneck_name in bottleneck_names:
            acts_path = (os.path.join(self.acts_dir, 'acts_{}_{}'.format(concept, bottleneck_name)) if self.acts_dir else None)
            if (acts_path and tf.gfile.Exists(acts_path)):
                with tf.gfile.Open(acts_path, 'rb') as f:
                    acts[concept][bottleneck_name] = np.load(f).squeeze()
                    tf.logging.info('Loaded {} shape {}'.format(acts_path, acts[concept][bottleneck_name].shape))
            else:
                acts[concept][bottleneck_name] = self.get_activations_for_concept(concept, bottleneck_name)
                if acts_path:
                    tf.logging.info('{} does not exist, Making one...'.format(acts_path))
                    with tf.gfile.Open(acts_path, 'w') as f:
                        np.save(f, acts[concept][bottleneck_name], allow_pickle=False)
    return acts