被自己蠢到哭的bug

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值