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


Python check.IsNone方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import IsNone [as 別名]
def __init__(self, tensor=None, array=None, stride=None, dim=None):
    """Creates ops for converting the input to either format.

    If 'tensor' is used, then a conversion from [stride * steps, dim] to
    [steps + 1, stride, dim] is performed for dynamic_tensor reads.

    If 'array' is used, then a conversion from [steps + 1, stride, dim] to
    [stride * steps, dim] is performed for bulk_tensor reads.

    Args:
      tensor: Bulk tensor input.
      array: TensorArray dynamic input.
      stride: stride of bulk tensor. Not used for dynamic.
      dim: dim of bulk tensor. Not used for dynamic.
    """
    if tensor is not None:
      check.IsNone(array, 'Cannot initialize from tensor and array')
      check.NotNone(stride, 'Stride is required for bulk tensor')
      check.NotNone(dim, 'Dim is required for bulk tensor')

      self._bulk_tensor = tensor
      with tf.name_scope('convert_to_dyn'):
        tensor = tf.reshape(tensor, [stride, -1, dim])
        tensor = tf.transpose(tensor, perm=[1, 0, 2])
        pad = tf.zeros([1, stride, dim], dtype=tensor.dtype)
        self._array_tensor = tf.concat([pad, tensor], 0)

    if array is not None:
      check.IsNone(tensor, 'Cannot initialize from both tensor and array')
      with tf.name_scope('convert_to_bulk'):
        self._bulk_tensor = convert_network_state_tensorarray(array)
      with tf.name_scope('convert_to_dyn'):
        self._array_tensor = array.stack() 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:35,代碼來源:network_units.py

示例2: testCheckIsNone

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

示例3: __init__

# 需要導入模塊: from syntaxnet.util import check [as 別名]
# 或者: from syntaxnet.util.check import IsNone [as 別名]
def __init__(self, tensor=None, array=None, stride=None, dim=None):
    """Creates ops for converting the input to either format.

    If 'tensor' is used, then a conversion from [stride * steps, dim] to
    [steps + 1, stride, dim] is performed for dynamic_tensor reads.

    If 'array' is used, then a conversion from [steps + 1, stride, dim] to
    [stride * steps, dim] is performed for bulk_tensor reads.

    Args:
      tensor: Bulk tensor input.
      array: TensorArray dynamic input.
      stride: stride of bulk tensor. Not used for dynamic.
      dim: dim of bulk tensor. Not used for dynamic.
    """
    if tensor is not None:
      check.IsNone(array, 'Cannot initialize from tensor and array')
      check.NotNone(stride, 'Stride is required for bulk tensor')
      check.NotNone(dim, 'Dim is required for bulk tensor')

      self._bulk_tensor = tensor
      if dim >= 0:
        # These operations will fail if |dim| is negative.
        with tf.name_scope('convert_to_dyn'):
          tensor = tf.reshape(tensor, [stride, -1, dim])
          tensor = tf.transpose(tensor, perm=[1, 0, 2])
          pad = tf.zeros([1, stride, dim], dtype=tensor.dtype)
          self._array_tensor = tf.concat([pad, tensor], 0)

    if array is not None:
      check.IsNone(tensor, 'Cannot initialize from both tensor and array')
      with tf.name_scope('convert_to_bulk'):
        self._bulk_tensor = convert_network_state_tensorarray(array)
      with tf.name_scope('convert_to_dyn'):
        self._array_tensor = array.stack() 
開發者ID:generalized-iou,項目名稱:g-tensorflow-models,代碼行數:37,代碼來源:network_units.py


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