1. TypeError: len is not well defined for symbolic Tensors. (packed_2:0) Please call x.shape
rather than len(x)
for shape information.
意思是tensor张量不能使用len()这个函数,可以把len(x_test)改为x_test.shape[0]同样可以得到测试集的长度。
2.ValueError: When using data tensors as input to a model, you should specify the steps_per_epoch
argument.
使用tensor张量输入到模型中,需要在fit函数中加入参数steps_per_epoch,但是将数据集转为张量的形式对我来说有点晕,所以最后的解决办法是将数据集转为numpy的形式输入到模型中,使用张量还是不习惯那。
3. UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
字面意思CUDNN出现问题了,有很多种情况都会出现这个错误,我第一次出现这个错误的原因是安装Nvidia显卡驱动时,cuDNN文件解压时放错了地方。第二次是将其他的模型的内存释放,最后可以尝试重启服务器。
4.ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 64, 64]
给数据增加一个维度,使数据和网络结构匹配[?,64,64,1]
x_train = x_train.reshape(x_train.shape[0], 64, 64, 1)
5.TypeError: Value passed to parameter ‘input’ has DataType uint8 not in list of allowed values: float32,float16
将输入模型的数组转为float32
img = tf.cast(img, tf.float32)
6.ValueError: ‘ReadVariableOp_1:value:0’ is not a valid scope name
命名不符合规则,去掉特殊字符或者没有目标文件夹