1. 文件读写编码
(1)有一行数据,我根据制表符分割后存储,然后再读取时,可以用line.decode(‘utf-8’)。
(2)但是如果先将数据转换为list,又转换为str,存储。再读取时,再用decode时就报错了。
原因:在写文件时 没有加encoding='utf-8', (2)的写法将其暴露出来。
解决方案:写文件时加encoding='utf-8',即 file=open(trn_file_output,'w',encoding='utf-8')
2. TypeError: Fetch argument 1 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
有多个tf.Tensor组成的list,想把list转化为tensor,就使用了tf.convet_to_tensor(list),因此报错。
解决办法:tf.stack(list)
3. File "...", line 270, in __init__
self._example_queue = Queue.Queue(self.BATCH_QUEUE_MAX * self._hps.batch_size)
TypeError: unsupported operand type(s) for *: 'int' and 'Flag'
将代码有tf1.4升级到tf1.12遇到的错误
解决办法:self._hps.batch_size改为self._hps.batch_size.value