当前位置: 首页>>代码示例>>Python>>正文


Python tf_inspect.getfullargspec方法代码示例

本文整理汇总了Python中tensorflow.python.util.tf_inspect.getfullargspec方法的典型用法代码示例。如果您正苦于以下问题:Python tf_inspect.getfullargspec方法的具体用法?Python tf_inspect.getfullargspec怎么用?Python tf_inspect.getfullargspec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.python.util.tf_inspect的用法示例。


在下文中一共展示了tf_inspect.getfullargspec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate

# 需要导入模块: from tensorflow.python.util import tf_inspect [as 别名]
# 或者: from tensorflow.python.util.tf_inspect import getfullargspec [as 别名]
def validate(host_calls):
    """Validates the `eval_metrics` and `host_call` in `TPUEstimatorSpec`."""

    for name, host_call in host_calls.items():
      if not isinstance(host_call, (tuple, list)):
        raise ValueError('{} should be tuple or list'.format(name))
      if len(host_call) != 2:
        raise ValueError('{} should have two elements.'.format(name))
      if not callable(host_call[0]):
        raise TypeError('{}[0] should be callable.'.format(name))
      if not isinstance(host_call[1], (tuple, list, dict)):
        raise ValueError('{}[1] should be tuple or list, or dict.'.format(name))

      if isinstance(host_call[1], (tuple, list)):
        fullargspec = tf_inspect.getfullargspec(host_call[0])
        fn_args = function_utils.fn_args(host_call[0])
        # wrapped_hostcall_with_global_step uses varargs, so we allow that.
        if fullargspec.varargs is None and len(host_call[1]) != len(fn_args):
          raise RuntimeError(
              'In TPUEstimatorSpec.{}, length of tensors {} does not match '
              'method args of the function, which takes {}.'.format(
                  name, len(host_call[1]), len(fn_args))) 
开发者ID:ymcui,项目名称:Chinese-XLNet,代码行数:24,代码来源:tpu_estimator.py

示例2: hook_loaded_model

# 需要导入模块: from tensorflow.python.util import tf_inspect [as 别名]
# 或者: from tensorflow.python.util.tf_inspect import getfullargspec [as 别名]
def hook_loaded_model(cls, loaded_model):
        try:
            from tensorflow.python.util import tf_inspect
            from tensorflow.python.eager import def_function
        except ImportError:
            raise MissingDependencyException(
                "Tensorflow package is required to use TfSavedModelArtifact"
            )

        for k in dir(loaded_model):
            v = getattr(loaded_model, k, None)
            if isinstance(v, def_function.Function):
                fullargspec = tf_inspect.getfullargspec(v)
                setattr(loaded_model, k, cls(v, fullargspec)) 
开发者ID:bentoml,项目名称:BentoML,代码行数:16,代码来源:tf_savedmodel_artifact.py

示例3: func_has_training_argument

# 需要导入模块: from tensorflow.python.util import tf_inspect [as 别名]
# 或者: from tensorflow.python.util.tf_inspect import getfullargspec [as 别名]
def func_has_training_argument(func):
  """Checks whether saved model has a `training` argument."""
  if not callable(func):
    return False
  fullargspec = tf_inspect.getfullargspec(func.__call__)
  return ("training" in fullargspec.args or
          "training" in fullargspec.kwonlyargs) 
开发者ID:tensorflow,项目名称:hub,代码行数:9,代码来源:keras_layer.py


注:本文中的tensorflow.python.util.tf_inspect.getfullargspec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。