代码调试
1、
ValueError: Negative dimension size caused by subtracting 2 from 1 for ‘{{node max_pooling2d_4/MaxPool}} = MaxPoolT=DT_FLOAT, data_format=“NHWC”, ksize=[1, 2, 2, 1], padding=“VALID”, strides=[1, 2, 2, 1]’ with input shapes: [?,1,16,128].
## 解决: input_shape=(C,H, W)是theano的写法,而tensorflow需要写出:(H, W,C)。
2、
AttributeError: module ‘tensorflow._api.v2.config’ has no attribute ‘experimental_list_devices’ ## 解决:
devices
= tf
.config
.list_logical_devices
()
_LOCAL_DEVICES
= [x
.name
for x
in devices
]
代码中红色替换为绿色
3、python2和python3中运算符的区别
TypeError: ‘float’ object cannot be interpreted as an integer
解决: 查看代码中是否含有/, python3的/结果含有浮点数! python2中的/等价于python3的// 在python3中,//表示取整除 - 返回商的整数部分(向下取整)