嗨,
我尝试使用tf_tande_v2工具将代码升级到tf 2,并得到以下错误:Traceback (most recent call last): File "/usr/local/bin/tf_upgrade_v2", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/tools/compatibility/tf_upgrade_v2_main.py", line 152, in main args.input_tree, output_tree, args.copy_other_files) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/tools/compatibility/ast_edits.py", line 1050, in process_tree _, l_report, l_errors = self.process_file(input_path, output_path) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/tools/compatibility/ast_edits.py", line 900, in process_file temp_file) File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/tools/compatibility/ast_edits.py", line 958, in process_opened_file lines = in_file.readlines() File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 786: ordinal not in range(128)
此错误的原因是encoder.py中的以下行:
网址:encoder.py
0574c57中的第19行
| | bs=list(range(ord("!"), ord("~")+1))+list(range(ord("¡"), ord("¬")+1))+list(range(ord("®"), ord("ÿ")+1)) |
我想我可以通过删除行绕过这个问题,转换代码,然后插入行回来.你认为这是一个有效的解决方案,或者也许它可以打破我没有想到的东西?谢谢.
1条答案
按热度按时间nbnkbykc1#
@Pavelrst,我使用
tf_upgrade_v2
,没有遇到任何问题,尽管我使用Python 3.8.1和TensorFlow 2.3.0不管怎样,文件
encoder.py
没有使用tensorflow
模块,所以不会受到脚本的影响,因为tf_upgrade_v2
主要是在代码中看到某些特定函数时,用tf.compat.v1
替换tf
。