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


Python array_ops.strided_slice_grad方法代碼示例

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


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

示例1: _StridedSliceGrad

# 需要導入模塊: from tensorflow.python.ops import array_ops [as 別名]
# 或者: from tensorflow.python.ops.array_ops import strided_slice_grad [as 別名]
def _StridedSliceGrad(op, grad):
  """Gradient for StridedSlice op."""
  x = array_ops.shape(op.inputs[0])
  begin = op.inputs[1]
  end = op.inputs[2]
  strides = op.inputs[3]

  return array_ops.strided_slice_grad(
      x,
      begin,
      end,
      strides,
      grad,
      begin_mask=op.get_attr("begin_mask"),
      end_mask=op.get_attr("end_mask"),
      ellipsis_mask=op.get_attr("ellipsis_mask"),
      new_axis_mask=op.get_attr("new_axis_mask"),
      shrink_axis_mask=op.get_attr("shrink_axis_mask")), None, None, None 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:20,代碼來源:array_grad.py

示例2: testHostVsDevice

# 需要導入模塊: from tensorflow.python.ops import array_ops [as 別名]
# 或者: from tensorflow.python.ops.array_ops import strided_slice_grad [as 別名]
def testHostVsDevice(self):
    with self.test_session(use_gpu=True) as sess:
      var2 = tf.Variable(
          tf.reshape(
              tf.cast(tf.range(1, 5, 1), tf.float32), shape=(4, 1, 1)))
      varshape = tf.Variable([6, 4, 4], dtype=tf.int32)
      sess.run(tf.global_variables_initializer())
      begin = tf.constant([0, 0, 0])
      end = tf.constant([4, 1, 1])
      strides = tf.constant([1, 1, 1])
      foo = array_ops.strided_slice_grad(varshape, begin, end, strides, var2)
      sess.run(foo) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:array_ops_test.py

示例3: testInt64Shape

# 需要導入模塊: from tensorflow.python.ops import array_ops [as 別名]
# 或者: from tensorflow.python.ops.array_ops import strided_slice_grad [as 別名]
def testInt64Shape(self):
    with self.test_session(use_gpu=True) as sess:
      original_dy = tf.reshape(
          tf.cast(tf.range(1, 5, 1), tf.float32), shape=(4, 1, 1))
      original_shape = tf.constant([6, 4, 4], dtype=tf.int64)
      sess.run(tf.global_variables_initializer())
      begin = tf.constant([0, 0, 0], dtype=tf.int64)
      end = tf.constant([4, 1, 1], dtype=tf.int64)
      strides = tf.constant([1, 1, 1], dtype=tf.int64)
      dx = array_ops.strided_slice_grad(original_shape, begin, end, strides,
                                        original_dy)
      sess.run(dx) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:array_ops_test.py

示例4: testMixedIndexTypes

# 需要導入模塊: from tensorflow.python.ops import array_ops [as 別名]
# 或者: from tensorflow.python.ops.array_ops import strided_slice_grad [as 別名]
def testMixedIndexTypes(self):
    with self.test_session(use_gpu=True) as sess:
      original_dy = tf.reshape(
          tf.cast(tf.range(1, 5, 1), tf.float32), shape=(4, 1, 1))
      original_shape = tf.constant([6, 4, 4], dtype=tf.int64)
      sess.run(tf.global_variables_initializer())
      begin = tf.constant([0, 0, 0], dtype=tf.int32)
      end = tf.constant([4, 1, 1], dtype=tf.int64)
      strides = tf.constant([1, 1, 1], dtype=tf.int64)
      with self.assertRaisesRegexp(
          TypeError, "Input 'begin' of 'StridedSliceGrad' Op has type int32"
          " that does not match type int64 of argument 'shape'"):
        dx = array_ops.strided_slice_grad(original_shape, begin, end, strides,
                                          original_dy)
        sess.run(dx) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:17,代碼來源:array_ops_test.py


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