python - 具有不同滤波器尺寸的 tensorflow 卷积

标签 python tensorflow conv-neural-network convolution

我想使用不同大小的过滤器对我的数据源进行卷积,并且想知道如何使用 Tensorflow 实现以下设置 enter image description here

换句话说,我想要两个并行卷积,并在将它们输入到完全连接层之前将它们连接到展平层中,但我不确定连接。

有关方法的任何代码片段或来源都会非常有帮助!

最佳答案

假设批量大小为 100,图像数据大小为 28x28x1。

import tensorflow as tf

inp = tf.placeholder(tf.float32, shape=[100, 28, 28, 1])
left_branch = tf.layers.conv2d(input=inp, filters=N, kernel_size=[L, M])
right_branch = tf.layers.conv2d(input=inp, filters=P, kernel_size=[R, S])

left_reshape = tf.reshape(left_branch, [100, num_outputs_in_left_branch])
right_reshape = tf.reshape(right_branch, [100, num_outputs_in_right_branch])

combined_branch = tf.concat([left_reshape, right_reshape], axis=1)
combined_branch = tf.layers.dense(combined_branch, num_units_in_dense)

关于python - 具有不同滤波器尺寸的 tensorflow 卷积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45069761/

相关文章:

tensorflow - 平面一维数据上的一维卷积(即无时间序列)

python - 如何覆盖 __init__ 同时保存继承自 OrderedDict 的旧 __init__

python - 如何从 python 3 中的嵌套列表中提取日期和第一次出现的数字之间的字符串?

tensorflow - keras GRU 层中的返回状态和返回序列有什么区别?

python - 运行export_inference_graph.py会给出类型差异错误

python - 合并 Conv2D 和 Dense 模型会导致 "RuntimeError: You must compile your model before using it.",尽管已经编译了合并的模型

java - 将手写笔记的图像转换为文本

python - 如何获得 helpers.bulk 函数(elasticsearch API)的 python 响应?

python - 箱内累积逻辑或

python - 没有名为 'scipy' 的模块