本文整理汇总了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
示例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)
示例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)
示例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)