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


Python check.Gt方法代碼示例

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


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

示例1: create_array

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import Gt [as 別名]
def create_array(self, stride):
    """Creates a new tensor array to store this layer's activations.

    Arguments:
      stride: Possibly dynamic batch * beam size with which to initialize the
        tensor array

    Returns:
      TensorArray object
    """
    check.Gt(self.dim, 0, 'Cannot create array when dimension is dynamic')
    tensor_array = ta.TensorArray(dtype=tf.float32,
                                  size=0,
                                  dynamic_size=True,
                                  clear_after_read=False,
                                  infer_shape=False,
                                  name='%s_array' % self.name)

    # Start each array with all zeros. Special values will still be learned via
    # the extra embedding dimension stored for each linked feature channel.
    initial_value = tf.zeros([stride, self.dim])
    return tensor_array.write(0, initial_value) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:24,代碼來源:network_units.py

示例2: __init__

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

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

    parameters = component.spec.network_unit.parameters
    self._num_slices = int(parameters['num_slices'])
    check.Gt(self._num_slices, 0, 'Invalid number of slices.')
    check.Eq(self._concatenated_input_dim % self._num_slices, 0,
             'Input dimension %s does not evenly divide into %s slices' %
             (self._concatenated_input_dim, self._num_slices))
    self._slice_dim = int(self._concatenated_input_dim / self._num_slices)

    for slice_index in xrange(self._num_slices):
      self._layers.append(
          Layer(self, 'slice_%s' % slice_index, self._slice_dim)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:21,代碼來源:network_units.py

示例3: create_array

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import Gt [as 別名]
def create_array(self, stride):
    """Creates a new tensor array to store this layer's activations.

    Arguments:
      stride: Possibly dynamic batch * beam size with which to initialize the
        tensor array

    Returns:
      TensorArray object
    """
    check.Gt(self.dim, 0, 'Cannot create array when dimension is dynamic')
    tensor_array = ta.TensorArray(
        dtype=tf.float32,
        size=0,
        dynamic_size=True,
        clear_after_read=False,
        infer_shape=False,
        name='%s_array' % self.name)

    # Start each array with all zeros. Special values will still be learned via
    # the extra embedding dimension stored for each linked feature channel.
    initial_value = tf.zeros([stride, self.dim])
    return tensor_array.write(0, initial_value) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:25,代碼來源:network_units.py

示例4: __init__

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

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

    parameters = component.spec.network_unit.parameters
    self._num_slices = int(parameters['num_slices'])
    check.Gt(self._num_slices, 0, 'Invalid number of slices.')
    check.Eq(self._concatenated_input_dim % self._num_slices, 0,
             'Input dimension %s does not evenly divide into %s slices' %
             (self._concatenated_input_dim, self._num_slices))
    self._slice_dim = int(self._concatenated_input_dim / self._num_slices)

    for slice_index in xrange(self._num_slices):
      self._layers.append(
          Layer(component, 'slice_%s' % slice_index, self._slice_dim)) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:21,代碼來源:network_units.py

示例5: fixed_feature_lookup

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import Gt [as 別名]
def fixed_feature_lookup(component, state, channel_id, stride):
  """Looks up fixed features and passes them through embeddings.

  Embedding vectors may be scaled by weights if the features specify it.

  Args:
    component: Component object in which to look up the fixed features.
    state: MasterState object for the live nlp_saft::dragnn::MasterState.
    channel_id: int id of the fixed feature to look up.
    stride: int Tensor of current batch * beam size.

  Returns:
    NamedTensor object containing the embedding vectors.
  """
  feature_spec = component.spec.fixed_feature[channel_id]
  check.Gt(feature_spec.embedding_dim, 0,
           'Embeddings requested for non-embedded feature: %s' % feature_spec)
  embedding_matrix = component.get_variable(fixed_embeddings_name(channel_id))

  with tf.op_scope([embedding_matrix], 'fixed_embedding_' + feature_spec.name):
    indices, ids, weights = dragnn_ops.extract_fixed_features(
        state.handle, component=component.name, channel_id=channel_id)
    size = stride * feature_spec.size
    embeddings = embedding_lookup(embedding_matrix, indices, ids, weights, size)
    dim = feature_spec.size * feature_spec.embedding_dim
    return NamedTensor(
        tf.reshape(embeddings, [-1, dim]), feature_spec.name, dim=dim) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:29,代碼來源:network_units.py

示例6: _validate_embedded_fixed_features

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import Gt [as 別名]
def _validate_embedded_fixed_features(comp):
  """Checks that the embedded fixed features of |comp| are set up properly."""
  for feature in comp.spec.fixed_feature:
    check.Gt(feature.embedding_dim, 0,
             'Embeddings requested for non-embedded feature: %s' % feature)
    if feature.is_constant:
      check.IsTrue(feature.HasField('pretrained_embedding_matrix'),
                   'Constant embeddings must be pretrained: %s' % feature) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:10,代碼來源:bulk_component.py

示例7: testCheckGt

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import Gt [as 別名]
def testCheckGt(self):
    check.Gt(2, 1, 'foo')
    with self.assertRaisesRegexp(ValueError, 'bar'):
      check.Gt(1, 1, 'bar')
    with self.assertRaisesRegexp(RuntimeError, 'baz'):
      check.Gt(-1, 1, 'baz', RuntimeError) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:8,代碼來源:check_test.py

示例8: fixed_feature_lookup

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import Gt [as 別名]
def fixed_feature_lookup(component, state, channel_id, stride):
  """Looks up fixed features and passes them through embeddings.

  Embedding vectors may be scaled by weights if the features specify it.

  Args:
    component: Component object in which to look up the fixed features.
    state: MasterState object for the live ComputeSession.
    channel_id: int id of the fixed feature to look up.
    stride: int Tensor of current batch * beam size.

  Returns:
    NamedTensor object containing the embedding vectors.
  """
  feature_spec = component.spec.fixed_feature[channel_id]
  check.Gt(feature_spec.embedding_dim, 0,
           'Embeddings requested for non-embedded feature: %s' % feature_spec)
  embedding_matrix = component.get_variable(fixed_embeddings_name(channel_id))

  with tf.op_scope([embedding_matrix], 'fixed_embedding_' + feature_spec.name):
    indices, ids, weights = dragnn_ops.extract_fixed_features(
        state.handle, component=component.name, channel_id=channel_id)
    size = stride * feature_spec.size
    embeddings = embedding_lookup(embedding_matrix, indices, ids, weights, size)
    dim = feature_spec.size * feature_spec.embedding_dim
    return NamedTensor(
        tf.reshape(embeddings, [-1, dim]), feature_spec.name, dim=dim) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:29,代碼來源:network_units.py


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