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


Python check.In方法代碼示例

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


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

示例1: get_attrs_with_defaults

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import In [as 別名]
def get_attrs_with_defaults(parameters, defaults):
  """Populates a dictionary with run-time attributes.

  Given defaults, populates any overrides from 'parameters' with their
  corresponding converted values. 'defaults' should be typed. This is useful
  for specifying NetworkUnit-specific configuration options.

  Args:
    parameters: a <string, string> map.
    defaults: a <string, value> typed set of default values.

  Returns:
    dictionary populated with any overrides.

  Raises:
    RuntimeError: if a key in parameters is not present in defaults.
  """
  attrs = defaults
  for key, value in parameters.iteritems():
    check.In(key, defaults, 'Unknown attribute: %s' % key)
    if isinstance(defaults[key], bool):
      attrs[key] = value.lower() == 'true'
    else:
      attrs[key] = type(defaults[key])(value)
  return attrs 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:27,代碼來源:network_units.py

示例2: __init__

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import In [as 別名]
def __init__(self, component):
    """Initializes weights and layers.

    Args:
      component: Parent ComponentBuilderBase object.
    """
    super(GatherNetwork, self).__init__(component)
    self._attrs = get_attrs_with_defaults(
        component.spec.network_unit.parameters, {'trainable_padding': False})

    check.In('indices', self._linked_feature_dims,
             'Missing required linked feature')
    check.Eq(self._linked_feature_dims['indices'], 1,
             'Wrong dimension for "indices" feature')
    self._dim = self._concatenated_input_dim - 1  # exclude 'indices'
    self._layers.append(Layer(component, 'outputs', self._dim))

    if self._attrs['trainable_padding']:
      self._params.append(
          tf.get_variable(
              'pre_padding', [1, 1, self._dim],
              initializer=tf.random_normal_initializer(stddev=1e-4),
              dtype=tf.float32)) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:25,代碼來源:network_units.py

示例3: __init__

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import In [as 別名]
def __init__(self, component):
    """Initializes weights and layers.

    Args:
      component: Parent ComponentBuilderBase object.
    """
    super(BiaffineDigraphNetwork, self).__init__(component)

    check.Eq(len(self._fixed_feature_dims.items()), 0,
             'Expected no fixed features')
    check.Eq(len(self._linked_feature_dims.items()), 2,
             'Expected two linked features')

    check.In('sources', self._linked_feature_dims,
             'Missing required linked feature')
    check.In('targets', self._linked_feature_dims,
             'Missing required linked feature')
    self._source_dim = self._linked_feature_dims['sources']
    self._target_dim = self._linked_feature_dims['targets']

    # TODO(googleuser): Make parameter initialization configurable.
    self._weights = []
    self._weights.append(tf.get_variable(
        'weights_arc', [self._source_dim, self._target_dim], tf.float32,
        tf.random_normal_initializer(stddev=1e-4)))
    self._weights.append(tf.get_variable(
        'weights_source', [self._source_dim], tf.float32,
        tf.random_normal_initializer(stddev=1e-4)))
    self._weights.append(tf.get_variable(
        'root', [self._source_dim], tf.float32,
        tf.random_normal_initializer(stddev=1e-4)))

    self._params.extend(self._weights)
    self._regularized_weights.extend(self._weights)

    # Negative Layer.dim indicates that the dimension is dynamic.
    self._layers.append(network_units.Layer(self, 'adjacency', -1)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:39,代碼來源:biaffine_units.py

示例4: __init__

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import In [as 別名]
def __init__(self, component):
    """Initializes weights and layers.

    Args:
      component: Parent ComponentBuilderBase object.
    """
    super(BiaffineDigraphNetwork, self).__init__(component)

    check.Eq(len(self._fixed_feature_dims.items()), 0,
             'Expected no fixed features')
    check.Eq(len(self._linked_feature_dims.items()), 2,
             'Expected two linked features')

    check.In('sources', self._linked_feature_dims,
             'Missing required linked feature')
    check.In('targets', self._linked_feature_dims,
             'Missing required linked feature')
    self._source_dim = self._linked_feature_dims['sources']
    self._target_dim = self._linked_feature_dims['targets']

    # TODO(googleuser): Make parameter initialization configurable.
    self._weights = []
    self._weights.append(tf.get_variable(
        'weights_arc', [self._source_dim, self._target_dim], tf.float32,
        tf.random_normal_initializer(stddev=1e-4)))
    self._weights.append(tf.get_variable(
        'weights_source', [self._source_dim], tf.float32,
        tf.random_normal_initializer(stddev=1e-4)))
    self._weights.append(tf.get_variable(
        'root', [self._source_dim], tf.float32,
        tf.random_normal_initializer(stddev=1e-4)))

    self._params.extend(self._weights)
    self._regularized_weights.extend(self._weights)

    # Negative Layer.dim indicates that the dimension is dynamic.
    self._layers.append(network_units.Layer(component, 'adjacency', -1)) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:39,代碼來源:biaffine_units.py

示例5: testCheckIn

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import In [as 別名]
def testCheckIn(self):
    check.In('a', ('a', 'b', 'c'), 'foo')
    check.In('b', {'a': 1, 'b': 2}, 'bar')
    with self.assertRaisesRegexp(ValueError, 'bar'):
      check.In('d', ('a', 'b', 'c'), 'bar')
    with self.assertRaisesRegexp(RuntimeError, 'baz'):
      check.In('c', {'a': 1, 'b': 2}, 'baz', RuntimeError) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:9,代碼來源:check_test.py

示例6: __init__

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import In [as 別名]
def __init__(self, component):
    """Initializes weights and layers.

    Args:
      component: Parent ComponentBuilderBase object.
    """
    super(BiaffineDigraphNetwork, self).__init__(component)

    check.Eq(len(self._fixed_feature_dims.items()), 0,
             'Expected no fixed features')
    check.Eq(len(self._linked_feature_dims.items()), 2,
             'Expected two linked features')

    check.In('sources', self._linked_feature_dims,
             'Missing required linked feature')
    check.In('targets', self._linked_feature_dims,
             'Missing required linked feature')
    self._source_dim = self._linked_feature_dims['sources']
    self._target_dim = self._linked_feature_dims['targets']

    self._weights = []
    self._weights.append(
        tf.get_variable('weights_arc', [self._source_dim, self._target_dim],
                        tf.float32, tf.orthogonal_initializer()))
    self._weights.append(
        tf.get_variable('weights_source', [self._source_dim], tf.float32,
                        tf.zeros_initializer()))
    self._weights.append(
        tf.get_variable('root', [self._source_dim], tf.float32,
                        tf.zeros_initializer()))

    self._params.extend(self._weights)
    self._regularized_weights.extend(self._weights)

    # Add runtime hooks for pre-computed weights.
    self._derived_params.append(self._get_root_weights)
    self._derived_params.append(self._get_root_bias)

    # Negative Layer.dim indicates that the dimension is dynamic.
    self._layers.append(network_units.Layer(component, 'adjacency', -1)) 
開發者ID:generalized-iou,項目名稱:g-tensorflow-models,代碼行數:42,代碼來源:biaffine_units.py

示例7: __init__

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import In [as 別名]
def __init__(self, component):
    """Initializes layers.

    Args:
      component: Parent ComponentBuilderBase object.
    """
    layers = [
        network_units.Layer(self, 'lengths', -1),
        network_units.Layer(self, 'scores', -1),
        network_units.Layer(self, 'logits', -1),
        network_units.Layer(self, 'arcs', -1),
    ]
    super(MstSolverNetwork, self).__init__(component, init_layers=layers)

    self._attrs = network_units.get_attrs_with_defaults(
        component.spec.network_unit.parameters,
        defaults={
            'forest': False,
            'loss': 'softmax',
            'crf_max_dynamic_range': 20,
        })

    check.Eq(
        len(self._fixed_feature_dims.items()), 0, 'Expected no fixed features')
    check.Eq(
        len(self._linked_feature_dims.items()), 2,
        'Expected two linked features')

    check.In('lengths', self._linked_feature_dims,
             'Missing required linked feature')
    check.In('scores', self._linked_feature_dims,
             'Missing required linked feature') 
開發者ID:generalized-iou,項目名稱:g-tensorflow-models,代碼行數:34,代碼來源:mst_units.py


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