我想使用不同大小的过滤器对我的数据源进行卷积,并且想知道如何使用 Tensorflow 实现以下设置
换句话说,我想要两个并行卷积,并在将它们输入到完全连接层之前将它们连接到展平层中,但我不确定连接。
有关方法的任何代码片段或来源都会非常有帮助!
最佳答案
假设批量大小为 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/