original_docstring: Build tensorflow graph for learning the metric.
  
  
      Args:
        n_cells : number of cells
        time_window : number of time bins fo responses used.
                      Currently support only time_window=1.
        lr : learning rate
        centers: location of centers for each cells (n_cells x 2)
        resolution : resolution of the grid in visual space,
                     where cell responses are embedded.
        layers : Architecture of the network.
                 Format - (a1, b1, c1, a2, b2, c2 .. ),
                 where (a, b, c) = (filter width, num of filters, stride)
        lam : L2 regularization on parameters of the network.'
        batch_norm : If batch-norm is applied between layers.
        is_training : if its training or testing (used for normalization layers)
        cell_type : Cell type information for each cell ( length: n_cells)
        cell_statistics : Mean firing rate of each cell
        triplet_type : Type of triplet used for training.
                       Loss modified accordingly.
        beta : Temperature parameter for soft-max loss.
      
docstring: Build tensorflow graph for learning the metric.
docstring_tokens: Build tensorflow graph for learning the metric .
code: def _build_graph(self, n_cells, time_window, lr, centers, resolution,
                     layers, lam, batch_norm, is_training, cell_type,
                     cell_statistics=None, triplet_type='a', beta=1):
      """Build tensorflow graph for learning the metric.
  
  
      Args:
        n_cells : number of cells
        time_window : number of time bins fo responses used.
                      Currently support only time_window=1.
        lr : learning rate
        centers: location of centers for each cells (n_cells x 2)
        resolution : resolution of the grid in visual space,
                     where cell responses are embedded.
        layers : Architecture of the network.
                 Format - (a1, b1, c1, a2, b2, c2 .. ),
                 where (a, b, c) = (filter width, num of filters, stride)
        lam : L2 regularization on parameters of the network.'
        batch_norm : If batch-norm is applied between layers.
        is_training : if its training or testing (used for normalization layers)
        cell_type : Cell type information for each cell ( length: n_cells)
        cell_statistics : Mean firing rate of each cell
        triplet_type : Type of triplet used for training.
                       Loss modified accordingly.
        beta : Temperature parameter for soft-max loss.
      """
  
      # account for triplet_type
      self.triplet_type = triplet_type
      self.beta = beta
  
      # make centers into grid points
      output_grid = self._give_cell_grid(centers, resolution)
      self.centers_grid, self.grid_size, self.map_cell_grid = output_grid
      self.map_cell_grid_tf = tf.constant(self.map_cell_grid.astype(np.float32))
  
      self.dim = n_cells * time_window
  
      self.cell_weights = self._get_cell_weights(cell_type, cell_statistics)
  
      self.layer_sizes = layers.split(',')
  
      # placeholders for anchor, pos and neg
      self.anchor = tf.placeholder(dtype=tf.float32,
                                   shape=[None, None, time_window],
                                   name='anchor')
      self.pos = tf.placeholder(dtype=tf.float32,
                                shape=[None, None, time_window], name='pos')
      self.neg = tf.placeholder(dtype=tf.float32,
                                shape=[None, None, time_window], name='neg')
  
      # embed anchor, pos, neg responses onto a 2D grid
      self.embed_anchor = self._embed_responses(self.anchor,
                                                self.map_cell_grid_tf,
                                                n_cells, self.grid_size,
                                                cell_type, reuse_variables=False)
  
      self.embed_pos = self._embed_responses(self.pos,
                                             self.map_cell_grid_tf,
                                             n_cells, self.grid_size,
                                             cell_type, reuse_variables=True)
  
      self.embed_neg = self._embed_responses(self.neg,
                                             self.map_cell_grid_tf,
                                             n_cells, self.grid_size,
                                             cell_type, reuse_variables=True)
  
      # embed anchor, pos, neg through a neural network
      self.nn_anchor = self._embed_network(self.embed_anchor,
                                           self.layer_sizes,
                                           reuse_variables=False,
                                           batch_norm=batch_norm,
                                           is_training=is_training)
  
      self.nn_pos = self._embed_network(self.embed_pos,
                                        self.layer_sizes,
                                        reuse_variables=True,
                                        batch_norm=batch_norm,
                                        is_training=is_training)
  
      self.nn_neg = self._embed_network(self.embed_neg,
                                        self.layer_sizes,
                                        reuse_variables=True,
                                        batch_norm=batch_norm,
                                        is_training=is_training)
  
      self.params = slim.get_model_variables() + [self.cell_weights]
  
      self._get_loss()
  
      l2_norm = [tf.nn.l2_loss(x) for x in self.params]
      loss_regularization = lam * tf.reduce_sum(l2_norm)
      self.loss = self.loss_triplet + loss_regularization
      self.train_step = tf.train.AdamOptimizer(lr).minimize(self.loss)
code_tokens: def _build_graph ( self , n_cells , time_window , lr , centers , resolution , layers , lam , batch_norm , is_training , cell_type , cell_statistics = None , triplet_type = 'a' , beta = 1 ) : self . triplet_type = triplet_type self . beta = beta output_grid = self . _give_cell_grid ( centers , resolution ) self . centers_grid , self . grid_size , self . map_cell_grid = output_grid self . map_cell_grid_tf = tf . constant ( self . map_cell_grid . astype ( np . float32 ) ) self . dim = n_cells * time_window self . cell_weights = self . _get_cell_weights ( cell_type , cell_statistics ) self . layer_sizes = layers . split ( ',' ) self . anchor = tf . placeholder ( dtype = tf . float32 , shape = [ None , None , time_window ] , name = 'anchor' ) self . pos = tf . placeholder ( dtype = tf . float32 , shape = [ None , None , time_window ] , name = 'pos' ) self . neg = tf . placeholder ( dtype = tf . float32 , shape = [ None , None , time_window ] , name = 'neg' ) self . embed_anchor = self . _embed_responses ( self . anchor , self . map_cell_grid_tf , n_cells , self . grid_size , cell_type , reuse_variables = False ) self . embed_pos = self . _embed_responses ( self . pos , self . map_cell_grid_tf , n_cells , self . grid_size , cell_type , reuse_variables = True ) self . embed_neg = self . _embed_responses ( self . neg , self . map_cell_grid_tf , n_cells , self . grid_size , cell_type , reuse_variables = True ) self . nn_anchor = self . _embed_network ( self . embed_anchor , self . layer_sizes , reuse_variables = False , batch_norm = batch_norm , is_training = is_training ) self . nn_pos = self . _embed_network ( self . embed_pos , self . layer_sizes , reuse_variables = True , batch_norm = batch_norm , is_training = is_training ) self . nn_neg = self . _embed_network ( self . embed_neg , self . layer_sizes , reuse_variables = True , batch_norm = batch_norm , is_training = is_training ) self . params = slim . get_model_variables ( ) + [ self . cell_weights ] self . _get_loss ( ) l2_norm = [ tf . nn . l2_loss ( x ) for x in self . params ] loss_regularization = lam * tf . reduce_sum ( l2_norm ) self . loss = self . loss_triplet + loss_regularization self . train_step = tf . train . AdamOptimizer ( lr ) . minimize ( self . loss )
short_docstring: Build tensorflow graph for learning the metric.
short_docstring_tokens: Build tensorflow graph for learning the metric .
comment: """Build tensorflow graph for learning the metric.
  
  
      Args:
        n_cells : number of cells
        time_window : number of time bins fo responses used.
                      Currently support only time_window=1.
        lr : learning rate
        centers: location of centers for each cells (n_cells x 2)
        resolution : resolution of the grid in visual space,
                     where cell responses are embedded.
        layers : Architecture of the network.
                 Format - (a1, b1, c1, a2, b2, c2 .. ),
                 where (a, b, c) = (filter width, num of filters, stride)
        lam : L2 regularization on parameters of the network.'
        batch_norm : If batch-norm is applied between layers.
        is_training : if its training or testing (used for normalization layers)
        cell_type : Cell type information for each cell ( length: n_cells)
        cell_statistics : Mean firing rate of each cell
        triplet_type : Type of triplet used for training.
                       Loss modified accordingly.
        beta : Temperature parameter for soft-max loss.
      """$SEP$# account for triplet_type$SEP$# make centers into grid points$SEP$# placeholders for anchor, pos and neg$SEP$# embed anchor, pos, neg responses onto a 2D grid$SEP$# embed anchor, pos, neg through a neural network