因此,我尝试使用 tf.int32
过滤器在 tf.int32
批处理上运行卷积(标准 depthwise_conv2d
) 。我收到错误:类型错误:传递给参数“输入”的值的 DataType int32 不在允许值列表中:float32、float64
。鉴于我不需要梯度,我想知道是否有人知道可以表达卷积并且接受整数的操作?谢谢!
最佳答案
你不能这样做,因为 conv2d不接受 int 类型:
input: A Tensor. Must be one of the following types: half, float32. A 4-D tensor. The dimension order is interpreted according to the value of data_format, see below for details.
因此,您的解决方案要么编写自己的 conv2dint (这只是不同类型的 conv2d 的副本),要么使用它们的 conv2d 并应用 tf.cast(res_from_conv, tf.int32)
.
关于python - 在 TensorFlow 中对整数张量进行卷积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44891665/