bilylee / SiamFC-TensorFlow

A TensorFlow implementation of the SiamFC tracker
MIT License
363 stars 112 forks source link

代码解答 #57

Closed dengyang1 closed 5 years ago

dengyang1 commented 6 years ago
templates = self.get_image_embedding(exemplar_images)
center_scale = int(get_center(track_config['num_scales']))
center_template = tf.identity(templates[center_scale])
templates = tf.stack([center_template for _ in range(track_config['num_scales'])])

with tf.variable_scope('target_template'):
  # Store template in Variable such that we don't have to feed this template every time.
  with tf.variable_scope('State'):
    state = tf.get_variable('exemplar',
                            initializer=tf.zeros(templates.get_shape().as_list(), dtype=templates.dtype),
                            trainable=False)
    with tf.control_dependencies([templates]):
      self.init = tf.assign(state, templates, validate_shape=True)
    self.templates = state

这是测试的一段代码.构造测试的template,我想问下这段代码的具体执行流程,非常感谢,因为我想修改代码,但是这一段测试代码没弄明白.感谢回复

bilylee commented 5 years ago

你好,

注意到

with tf.control_dependencies([templates]):
      self.init = tf.assign(state, templates, validate_shape=True)

因此,在 sess. run 执行 self.init 时,这段代码首先计算 templates, 然后将 templates 保存到 state Variable 中。