本文记录本小白在使用tensorflow的过程中遇到的一些问题及解决方法,以防止日后再遇到同样的问题而不知所措
Failed to get convolution algorithm. This is probably because cuDNN failed to initialize
报错给人一种误导,让人误以为cuda和cudnn版本不匹配之类的问题,实际上还有可能是因为你的显存不足而出错,解决方法是可以先在程序前添加以下代码,它的作用是对GPU按需分配
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
参考链接
ValueError: invalid literal for int() with base 10:
原代码:
idx_label = dict(((int(idx), label) for idx, label in tokens))
上网查看发现说是字符串里是浮点型,应该先用float再用int转换
idx_label = dict(((int(float(idx)), label) for idx, label in tokens))
尝试之后发现还是不行,因为我这字符串里有英文字母(csv文件里的数据名称),我自己尝试着给分片,这个错误倒是解决了,不知道还会不会引发别的错误
idx_label = dict(((int(idx.split('.' ,1)[0]), label) for idx, label in tokens))
‘DataFrame’ object has no attribute ‘icol’
问题原因:opencv版本更新后不再支持icol提取列数据,可以使用iloc代替:
csvdata.icol[0]
csvdata.iloc[:, 0]