當前位置: 首頁>>代碼示例>>Python>>正文


Python variables_helper.get_variables_available_in_checkpoint方法代碼示例

本文整理匯總了Python中object_detection.utils.variables_helper.get_variables_available_in_checkpoint方法的典型用法代碼示例。如果您正苦於以下問題:Python variables_helper.get_variables_available_in_checkpoint方法的具體用法?Python variables_helper.get_variables_available_in_checkpoint怎麽用?Python variables_helper.get_variables_available_in_checkpoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在object_detection.utils.variables_helper的用法示例。


在下文中一共展示了variables_helper.get_variables_available_in_checkpoint方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_return_variables_available_an_checkpoint_with_dict_inputs

# 需要導入模塊: from object_detection.utils import variables_helper [as 別名]
# 或者: from object_detection.utils.variables_helper import get_variables_available_in_checkpoint [as 別名]
def test_return_variables_available_an_checkpoint_with_dict_inputs(self):
    checkpoint_path = os.path.join(self.get_temp_dir(), 'graph.pb')
    graph1_variables = [
        tf.Variable(1.0, name='ckpt_weights'),
    ]
    init_op = tf.global_variables_initializer()
    saver = tf.train.Saver(graph1_variables)
    with self.test_session() as sess:
      sess.run(init_op)
      saver.save(sess, checkpoint_path)

    graph2_variables_dict = {
        'ckpt_weights': tf.Variable(1.0, name='weights'),
        'ckpt_biases': tf.Variable(1.0, name='biases')
    }
    out_variables = variables_helper.get_variables_available_in_checkpoint(
        graph2_variables_dict, checkpoint_path)
    self.assertTrue(isinstance(out_variables, dict))
    self.assertItemsEqual(out_variables.keys(), ['ckpt_weights'])
    self.assertTrue(out_variables['ckpt_weights'].op.name == 'weights') 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:22,代碼來源:variables_helper_test.py

示例2: test_return_variables_available_in_checkpoint

# 需要導入模塊: from object_detection.utils import variables_helper [as 別名]
# 或者: from object_detection.utils.variables_helper import get_variables_available_in_checkpoint [as 別名]
def test_return_variables_available_in_checkpoint(self):
    checkpoint_path = os.path.join(self.get_temp_dir(), 'model.ckpt')
    with tf.Graph().as_default():
      weight_variable = tf.Variable(1.0, name='weights')
      global_step = tf.train.get_or_create_global_step()
      graph1_variables = [
          weight_variable,
          global_step
      ]
      init_op = tf.global_variables_initializer()
      saver = tf.train.Saver(graph1_variables)
      with self.test_session() as sess:
        sess.run(init_op)
        saver.save(sess, checkpoint_path)

    with tf.Graph().as_default():
      graph2_variables = graph1_variables + [tf.Variable(1.0, name='biases')]
      out_variables = variables_helper.get_variables_available_in_checkpoint(
          graph2_variables, checkpoint_path, include_global_step=False)
    self.assertItemsEqual(out_variables, [weight_variable]) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:22,代碼來源:variables_helper_test.py

示例3: test_return_variables_available_an_checkpoint_with_dict_inputs

# 需要導入模塊: from object_detection.utils import variables_helper [as 別名]
# 或者: from object_detection.utils.variables_helper import get_variables_available_in_checkpoint [as 別名]
def test_return_variables_available_an_checkpoint_with_dict_inputs(self):
    checkpoint_path = os.path.join(self.get_temp_dir(), 'model.ckpt')
    with tf.Graph().as_default():
      graph1_variables = [
          tf.Variable(1.0, name='ckpt_weights'),
      ]
      init_op = tf.global_variables_initializer()
      saver = tf.train.Saver(graph1_variables)
      with self.test_session() as sess:
        sess.run(init_op)
        saver.save(sess, checkpoint_path)

    with tf.Graph().as_default():
      graph2_variables_dict = {
          'ckpt_weights': tf.Variable(1.0, name='weights'),
          'ckpt_biases': tf.Variable(1.0, name='biases')
      }
      out_variables = variables_helper.get_variables_available_in_checkpoint(
          graph2_variables_dict, checkpoint_path)

    self.assertTrue(isinstance(out_variables, dict))
    self.assertItemsEqual(out_variables.keys(), ['ckpt_weights'])
    self.assertTrue(out_variables['ckpt_weights'].op.name == 'weights') 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:25,代碼來源:variables_helper_test.py

示例4: test_return_variables_available_in_checkpoint

# 需要導入模塊: from object_detection.utils import variables_helper [as 別名]
# 或者: from object_detection.utils.variables_helper import get_variables_available_in_checkpoint [as 別名]
def test_return_variables_available_in_checkpoint(self):
    checkpoint_path = os.path.join(self.get_temp_dir(), 'graph.pb')
    weight_variable = tf.Variable(1.0, name='weights')
    global_step = tf.train.get_or_create_global_step()
    graph1_variables = [
        weight_variable,
        global_step
    ]
    init_op = tf.global_variables_initializer()
    saver = tf.train.Saver(graph1_variables)
    with self.test_session() as sess:
      sess.run(init_op)
      saver.save(sess, checkpoint_path)

    graph2_variables = graph1_variables + [tf.Variable(1.0, name='biases')]
    out_variables = variables_helper.get_variables_available_in_checkpoint(
        graph2_variables, checkpoint_path, include_global_step=False)
    self.assertItemsEqual(out_variables, [weight_variable]) 
開發者ID:cagbal,項目名稱:ros_people_object_detection_tensorflow,代碼行數:20,代碼來源:variables_helper_test.py

示例5: test_return_variables_with_correct_sizes

# 需要導入模塊: from object_detection.utils import variables_helper [as 別名]
# 或者: from object_detection.utils.variables_helper import get_variables_available_in_checkpoint [as 別名]
def test_return_variables_with_correct_sizes(self):
    checkpoint_path = os.path.join(self.get_temp_dir(), 'graph.pb')
    bias_variable = tf.Variable(3.0, name='biases')
    global_step = tf.train.get_or_create_global_step()
    graph1_variables = [
        tf.Variable([[1.0, 2.0], [3.0, 4.0]], name='weights'),
        bias_variable,
        global_step
    ]
    init_op = tf.global_variables_initializer()
    saver = tf.train.Saver(graph1_variables)
    with self.test_session() as sess:
      sess.run(init_op)
      saver.save(sess, checkpoint_path)

    graph2_variables = [
        tf.Variable([1.0, 2.0], name='weights'),  # Note the new variable shape.
        bias_variable,
        global_step
    ]

    out_variables = variables_helper.get_variables_available_in_checkpoint(
        graph2_variables, checkpoint_path, include_global_step=True)
    self.assertItemsEqual(out_variables, [bias_variable, global_step]) 
開發者ID:cagbal,項目名稱:ros_people_object_detection_tensorflow,代碼行數:26,代碼來源:variables_helper_test.py

示例6: test_return_all_variables_from_checkpoint_with_partition

# 需要導入模塊: from object_detection.utils import variables_helper [as 別名]
# 或者: from object_detection.utils.variables_helper import get_variables_available_in_checkpoint [as 別名]
def test_return_all_variables_from_checkpoint_with_partition(self):
    with tf.Graph().as_default():
      partitioner = tf.fixed_size_partitioner(2)
      variables = [
          tf.get_variable(
              name='weights', shape=(2, 2), partitioner=partitioner),
          tf.Variable([1.0, 2.0], name='biases')
      ]
      checkpoint_path = os.path.join(self.get_temp_dir(), 'model.ckpt')
      init_op = tf.global_variables_initializer()
      saver = tf.train.Saver(variables)
      with self.test_session() as sess:
        sess.run(init_op)
        saver.save(sess, checkpoint_path)
      out_variables = variables_helper.get_variables_available_in_checkpoint(
          variables, checkpoint_path)
    self.assertItemsEqual(out_variables, variables) 
開發者ID:ShivangShekhar,項目名稱:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代碼行數:19,代碼來源:variables_helper_test.py


注:本文中的object_detection.utils.variables_helper.get_variables_available_in_checkpoint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。