• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python nn_ops.conv2d_backprop_filter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tensorflow.python.ops.nn_ops.conv2d_backprop_filter函数的典型用法代码示例。如果您正苦于以下问题:Python conv2d_backprop_filter函数的具体用法?Python conv2d_backprop_filter怎么用?Python conv2d_backprop_filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了conv2d_backprop_filter函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testGradientDilatedConv

 def testGradientDilatedConv(self):
   if test.is_gpu_available(cuda_only=True):
     with self.test_session(use_gpu=True):
       for padding in ["SAME", "VALID"]:
         for stride in [1, 2]:
           np.random.seed(1)
           in_shape = [5, 8, 6, 4]
           in_val = constant_op.constant(
               2 * np.random.random_sample(in_shape) - 1, dtype=dtypes.float32)
           filter_shape = [3, 3, 4, 6]
           # Make a convolution op with the current settings,
           # just to easily get the shape of the output.
           conv_out = nn_ops.conv2d(
               in_val,
               array_ops.zeros(filter_shape),
               dilations=[1, 2, 2, 1],
               strides=[1, stride, stride, 1],
               padding=padding)
           out_backprop_shape = conv_out.get_shape().as_list()
           out_backprop_val = constant_op.constant(
               2 * np.random.random_sample(out_backprop_shape) - 1,
               dtype=dtypes.float32)
           output = nn_ops.conv2d_backprop_filter(
               in_val,
               filter_shape,
               out_backprop_val,
               dilations=[1, 2, 2, 1],
               strides=[1, stride, stride, 1],
               padding=padding)
           err = gradient_checker.compute_gradient_error(
               [in_val, out_backprop_val], [in_shape, out_backprop_shape],
               output, filter_shape)
           print("conv2d_backprop_filter gradient err = %g " % err)
           err_tolerance = 2e-3
           self.assertLess(err, err_tolerance)
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:35,代码来源:conv2d_backprop_filter_grad_test.py


示例2: _Conv2DBackpropInputGrad

def _Conv2DBackpropInputGrad(op, grad):
  """The derivatives for deconvolution.

  Args:
    op: the Deconvolution op.
    grad: the tensor representing the gradient w.r.t. the output

  Returns:
    the gradients w.r.t. the input and the filter
  """
  return [
      None,
      nn_ops.conv2d_backprop_filter(
          grad,
          array_ops.shape(op.inputs[1]),
          op.inputs[2],
          dilations=op.get_attr("dilations"),
          strides=op.get_attr("strides"),
          padding=op.get_attr("padding"),
          use_cudnn_on_gpu=op.get_attr("use_cudnn_on_gpu"),
          data_format=op.get_attr("data_format").decode()),
      nn_ops.conv2d(
          grad,
          op.inputs[1],
          dilations=op.get_attr("dilations"),
          strides=op.get_attr("strides"),
          padding=op.get_attr("padding"),
          use_cudnn_on_gpu=op.get_attr("use_cudnn_on_gpu"),
          data_format=op.get_attr("data_format").decode())
  ]
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:30,代码来源:nn_grad.py


示例3: _Conv2DGrad

def _Conv2DGrad(op, grad):
  dilations = op.get_attr("dilations")
  strides = op.get_attr("strides")
  padding = op.get_attr("padding")
  use_cudnn_on_gpu = op.get_attr("use_cudnn_on_gpu")
  data_format = op.get_attr("data_format")
  shape_0, shape_1 = array_ops.shape_n([op.inputs[0], op.inputs[1]])
  return [
      nn_ops.conv2d_backprop_input(
          shape_0,
          op.inputs[1],
          grad,
          dilations=dilations,
          strides=strides,
          padding=padding,
          use_cudnn_on_gpu=use_cudnn_on_gpu,
          data_format=data_format),
      nn_ops.conv2d_backprop_filter(
          op.inputs[0],
          shape_1,
          grad,
          dilations=dilations,
          strides=strides,
          padding=padding,
          use_cudnn_on_gpu=use_cudnn_on_gpu,
          data_format=data_format)
  ]
开发者ID:Huoxubeiyin,项目名称:tensorflow,代码行数:27,代码来源:nn_grad.py


示例4: _Conv2DGrad

def _Conv2DGrad(op, grad):
    return [
        nn_ops.conv2d_backprop_input(
            array_ops.shape(op.inputs[0]), op.inputs[1], grad, op.get_attr("strides"), op.get_attr("padding")
        ),
        nn_ops.conv2d_backprop_filter(
            op.inputs[0], array_ops.shape(op.inputs[1]), grad, op.get_attr("strides"), op.get_attr("padding")
        ),
    ]
开发者ID:swapnilashtekar,项目名称:tensorflow,代码行数:9,代码来源:nn_grad.py


示例5: testBackwardFilterGradient

 def testBackwardFilterGradient(self):
   np.random.seed(1)
   in_shape = LayerShape(batch=8, height=128, width=128, channels=8)
   filter_shape = FilterShape(height=3, width=3, in_channels=8, out_channels=8)
   in_op = self._random_data_op(in_shape)
   out_op = self._random_out_op(in_shape, filter_shape)
   filter_gradient_op = nn_ops.conv2d_backprop_filter(
       in_op, filter_shape, out_op, strides=_STRIDES, padding=_PADDING)
   self._assert_reproducible(filter_gradient_op)
开发者ID:kylin9872,项目名称:tensorflow,代码行数:9,代码来源:cudnn_determinism_test.py


示例6: _DeConv2DGrad

def _DeConv2DGrad(op, grad):
    """The derivatives for deconvolution.

  Args:
    op: the Deconvolution op.
    grad: the tensor representing the gradient w.r.t. the output

  Returns:
    the gradients w.r.t. the input and the filter
  """
    return [
        None,
        nn_ops.conv2d_backprop_filter(
            grad, array_ops.shape(op.inputs[1]), op.inputs[2], op.get_attr("strides"), op.get_attr("padding")
        ),
        nn_ops.conv2d(grad, op.inputs[1], op.get_attr("strides"), op.get_attr("padding")),
    ]
开发者ID:swapnilashtekar,项目名称:tensorflow,代码行数:17,代码来源:nn_grad.py


示例7: _Conv2DGrad

def _Conv2DGrad(op, grad):
    return [
        nn_ops.conv2d_backprop_input(
            array_ops.shape(op.inputs[0]),
            op.inputs[1],
            grad,
            op.get_attr("strides"),
            op.get_attr("padding"),
            op.get_attr("use_cudnn_on_gpu"),
            op.get_attr("data_format"),
        ),
        nn_ops.conv2d_backprop_filter(
            op.inputs[0],
            array_ops.shape(op.inputs[1]),
            grad,
            op.get_attr("strides"),
            op.get_attr("padding"),
            op.get_attr("use_cudnn_on_gpu"),
            op.get_attr("data_format"),
        ),
    ]
开发者ID:adsar,项目名称:tensorflow,代码行数:21,代码来源:nn_grad.py



注:本文中的tensorflow.python.ops.nn_ops.conv2d_backprop_filter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nn_ops.conv2d_backprop_input函数代码示例发布时间:2022-05-27
下一篇:
Python nn_ops.conv2d函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap