Complex convolution in tensorflow

青春壹個敷衍的年華 提交于 2019-12-07 15:41:11

问题


I'm trying to run a simple convolution but with complex numbers:

r = np.random.random([1,10,10,10])
i = np.random.random([1,10,10,10])
x = tf.complex(r,i)

conv_layer = tf.layers.conv2d(
            inputs=x,
            filters=10,
            kernel_size=[3,3],
            kernel_initializer=utils.truncated_normal_complex(),
            activation=tf.nn.sigmoid)

However I get this error:

TypeError: Value passed to parameter 'input' has DataType complex128 not in list of allowed values: float16, float32

Does anyone know how to implement such a convolution in Tensorflow?

Will I need to implement a custom op, or is there some better option here?

Frustratingly, complex matrix multiplication is possible, e.g. the following runs fine:

def r():
    return np.random.random([10,10])
A = tf.complex(r(),r())
B = tf.complex(r(),r())
C = tf.multiply(A,B)
sess.run(C)

So there's no real reason convolution shouldn't work, I would think (as convolution is essentially just matrix multiplication).

Thanks

来源:https://stackoverflow.com/questions/47577458/complex-convolution-in-tensorflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!