python - 在 TensorFlow 中对整数张量进行卷积

标签 python tensorflow

因此,我尝试使用 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/

相关文章:

python - LSTM 不会过度拟合训练数据

tensorflow - tensorflow::port::InitMain 的目的是什么?

python - 如何在 Tensorflow 2.0 中复制网络

python - 在 Python 中从 URL 中删除 utm_* 参数

python - 如何使用 ElementTree 在 python 中复制 xml 树?

python - 在现有占位符中插入文本并设置其格式

python - 如何按比例调整 QTableView 中的列宽?

python - 为什么base64解码字符串在Python2.7和Linux中不一样

python - tensorflow : How to use restored model?

python - tensorflow : Transform class name to class index