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


Python tensorflow_hub.load_module_spec方法代碼示例

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


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

示例1: eval_from_hub

# 需要導入模塊: import tensorflow_hub [as 別名]
# 或者: from tensorflow_hub import load_module_spec [as 別名]
def eval_from_hub(model_dir, input_fn, eval_steps):
  """Eval using hub module."""
  hub_module_spec = hub.load_module_spec(model_dir)
  run_config = tf.estimator.RunConfig(model_dir=model_dir)
  image_classifier = tf.estimator.Estimator(
      model_fn=_make_model_fn(hub_module_spec), config=run_config, params={})
  eval_results = image_classifier.evaluate(input_fn=input_fn, steps=eval_steps)
  tf.logging.info('Evaluation results: %s' % eval_results) 
開發者ID:mlperf,項目名稱:training_results_v0.5,代碼行數:10,代碼來源:tf_hub.py

示例2: get_text_module_input_name

# 需要導入模塊: import tensorflow_hub [as 別名]
# 或者: from tensorflow_hub import load_module_spec [as 別名]
def get_text_module_input_name():
  """Get the tag used for inputs to the text module.

  Returns:
    a string, probably "default"
  """
  module_spec = hub.load_module_spec(FLAGS.module_handle)
  return list(module_spec.get_input_info_dict())[0] 
開發者ID:google-research,項目名稱:language,代碼行數:10,代碼來源:metaqa.py

示例3: __init__

# 需要導入模塊: import tensorflow_hub [as 別名]
# 或者: from tensorflow_hub import load_module_spec [as 別名]
def __init__(self,
               tf_hub_module_spec=None,
               tf_hub_module_path=None,):
    """Creates an instance to extract image features from a pre-trained model.

    The model to use may be specified as a TF-hub module (either by ModuleSpec
    or path) or as an Inception V4 model checkpoint.

    If a TF-hub module is given, it is assumed to conform to the interface
    described in [1]. Its default signature should take an input 'images' Tensor
    with shape [batch_size, height, width, num_channels=3] and return a
    [batch_size, feature_dim] Tensor of features. Pass
    `tf_hub_module_spec=make_module_spec_for_testing()` to stub out the model
    for tests.

    [1]
    https://www.tensorflow.org/hub/common_signatures/images#image_feature_vector

    Args:
      tf_hub_module_spec: `hub.ModuleSpec` or None, the TF-hub module to load.
      tf_hub_module_path: str or None, the location of the TF-hub module to load
        in a format understood by `load_module_spec()` (URL,
        '@internal/module/name', '/on/disk/path', etc.)

    Raises:
      ValueError: if not exactly one kwarg specifying the model is given.
    """
    self.spec_str = None  # String describing the model/module being used.

    # Input and output tensors for the image to representation computation.
    # The output tensor will depend on the model options.
    self._input = None
    self._output = None
    self._session = None

    num_kwargs = sum(
        int(kwarg is not None) for kwarg in
        [tf_hub_module_spec, tf_hub_module_path])
    if num_kwargs != 1:
      raise ValueError(
          'Must provide exactly one of "tf_hub_module_spec", '
          '"tf_hub_module_path".')

    if tf_hub_module_spec:
      self.spec_str = 'user_provided_module'
      self._initialize_from_hub_module(tf_hub_module_spec)
    elif tf_hub_module_path:
      self.spec_str = tf_hub_module_path
      self._initialize_from_hub_module(hub.load_module_spec(tf_hub_module_path)) 
開發者ID:google-research,項目名稱:valan,代碼行數:51,代碼來源:tf_image_processor.py


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