tensorflow学习笔记(十三):conv3d

conv3d

tf.nn.conv3d(input, filter, strides, padding, name=None)

Computes a 3-D convolution given 5-D input and filter tensors.

In signal processing, cross-correlation is a measure of similarity of two waveforms as a function of a time-lag applied to one of them. This is also known as a sliding dot product or sliding inner-product.

Our Conv3D implements a form of cross-correlation.

Args:

input: A Tensor. Must be one of the following types: float32, float64, int64, int32, uint8, uint16, int16, int8, complex64, complex128, qint8, quint8, qint32, half. Shape [batch, in_depth, in_height, in_width, in_channels].
filter: A Tensor. Must have the same type as input. Shape [filter_depth, filter_height, filter_width, in_channels, out_channels]. in_channels must match between input and filter.
strides: A list of ints that has length >= 5. 1-D tensor of length 5. The stride of the sliding window for each dimension of input. Must have strides[0] = strides[4] = 1.
padding: A string from: "SAME", "VALID". The type of padding algorithm to use.
name: A name for the operation (optional).
Returns:

A Tensor. Has the same type as input.

这是官方给的解释,还不如conv2d解释的详细呢,至少在介绍conv2d的时候还给了公式.
和conv2d对比一下:

  • 在input的shape中多了个 in_depth(代表一个sample输入几个帧,每帧代表一个图片).
  • filter的shape也多个 filter_depth.在conv2d中, filter_height, filter_height构成感受眼的大小.在conv3d中,由filter_depth,filter_height,filter_width构成了感受眼的大小
  • strides中也多了一维,[strides_batch,strides_depth,strides_height,strides_width,strides_channel],
    和conv2d相同的地方
  • 虽然多了一维,但是参数表示的意思和conv2d时是一样的,in_channels依旧是代表输入图片的channels,(e.g.RGB图像的in_channels还是3)
  • out_channels(卷积核的个数, 一个卷积核的shape是 [depth, height, width]
    这里写图片描述

Pooling

和卷积一样理解就可以了

tf.nn.avg_pool3d(input, ksize, strides, padding, name=None)

Performs 3D average pooling on the input.

Args:

input: A Tensor. Must be one of the following types: float32, float64, int64, int32, uint8, uint16, int16, int8, complex64, complex128, qint8, quint8, qint32, half. Shape [batch, depth, rows, cols, channels] tensor to pool over.
ksize: A list of ints that has length >= 5. 1-D tensor of length 5. The size of the window for each dimension of the input tensor. Must have ksize[0] = ksize[4] = 1.
strides: A list of ints that has length >= 5. 1-D tensor of length 5. The stride of the sliding window for each dimension of input. Must have strides[0] = strides[4] = 1.
padding: A string from: "SAME", "VALID". The type of padding algorithm to use.
name: A name for the operation (optional).
Returns:

A Tensor. Has the same type as input. The average pooled output tensor.
tf.nn.max_pool3d(input, ksize, strides, padding, name=None)

Performs 3D max pooling on the input.

Args:

input: A Tensor. Must be one of the following types: float32, float64, int64, int32, uint8, uint16, int16, int8, complex64, complex128, qint8, quint8, qint32, half. Shape [batch, depth, rows, cols, channels] tensor to pool over.
ksize: A list of ints that has length >= 5. 1-D tensor of length 5. The size of the window for each dimension of the input tensor. Must have ksize[0] = ksize[4] = 1.
strides: A list of ints that has length >= 5. 1-D tensor of length 5. The stride of the sliding window for each dimension of input. Must have strides[0] = strides[4] = 1.
padding: A string from: "SAME", "VALID". The type of padding algorithm to use.
name: A name for the operation (optional).
Returns:

A Tensor. Has the same type as input. The max pooled output tensor.
  • 6
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
出现 'tensorflow' has no attribute 'Conv1d' 的错误是因为在当前版本的 TensorFlow 中没有名为 'Conv1d' 的函数或属性。这可能是由于使用了不兼容的版本或 API 更改导致的。 要解决这个问题,有几个步骤可以尝试: 1. 检查 TensorFlow 的版本:确保您正在使用的 TensorFlow 版本支持 'Conv1d' 函数。您可以通过使用以下代码片段来检查 TensorFlow 的版本: ``` import tensorflow as tf print(tf.__version__) ``` 如果输出的版本号小于 2.x,那么您可以尝试升级 TensorFlow 到最新版本以获得最新的功能和 API。 2. 检查函数名称:确认您的代码中是否正确使用了函数名称。有时候可能会因为拼写错误或误用了不正确的函数名称而导致该错误。 3. 使用 TensorFlow 的兼容性模块:根据您提供的引用,您可以尝试使用 `tensorflow.compat.v1` 模块来解决该问题。在这个模块中,您可以尝试使用 `tf.compat.v1.layers.Conv1D` 来替代 `tf.Conv1d`。请确保在导入时使用 `import tensorflow.compat.v1 as tf` 来引用该模块。 4. 安装特定版本的 TensorFlow:根据您提供的引用,您可以尝试卸载当前的 TensorFlow,并使用指定版本(例如 1.2.0)来重新安装。请注意,在安装指定版本之前,请确保您已经卸载了当前的 TensorFlow。 请注意,这些步骤只是一些常见的解决方法,具体取决于您的使用情况和代码实现。如果以上方法不起作用,可以尝试查找更多关于 'Conv1d' 函数的相关文档或寻求更详细的帮助以解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Tensorflow出现AttributeError: module ‘tensorflow‘ has no attribute ‘constant‘问题怎么办?](https://blog.csdn.net/u011412226/article/details/79792379)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [AttributeError: module 'tensorflow.compat.v1' has no attribute '](https://download.csdn.net/download/qq_38766019/86272235)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [AttributeError: module ‘tensorflow‘ has no attribute ‘convert_to_tensor](https://blog.csdn.net/seraph_studio/article/details/117857271)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值