Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are errors in the source code(源代码写的有错误) #1163

Open
SB-Moloo opened this issue Nov 29, 2023 · 0 comments
Open

There are errors in the source code(源代码写的有错误) #1163

SB-Moloo opened this issue Nov 29, 2023 · 0 comments

Comments

@SB-Moloo
Copy link

In English:
tensorlayer2.2.5
function _load_weights_from_hdf5_group_in_order() have errors in:
layer_names = [n.decode('utf8') for n in f.attrs["layer_names"]].
Need to be modified to:
layer_names = [n if isinstance(n, str) else n.decode('utf8') for n in f.attrs["layer_names"]].
in line 2605 and 2617.

In Chinese:
tensorlayer2.2.5源码错误:
tl.files.load_hdf5_to_weights_in_order()
这个库的读取模型的代码编写有误,就是上面这个函数,他会报错说:AttributeError: 'str' object has no attribute 'decode'
我们可以点进去上面这个函数去看看,注意不要点错了,这个函数里面还调用了一个函数:_load_weights_from_hdf5_group_in_order
就是这个内部调用的函数写的有问题。
我们可以看看他这个不带_前缀的函数,代码是怎么写的:
layer_names = [n if isinstance(n, str) else n.decode('utf8') for n in f.attrs["layer_names"]]
他n.decode('utf8')前先做了个判断,而带_前缀的函数里面点进去看看,它是这么写的:
layer_names = [n.decode('utf8') for n in f.attrs["layer_names"]]
这就是错误所在,把这个带_前缀的函数里所有的 n.decode('utf8') 替换成 n if isinstance(n, str) else n.decode('utf8') 即可
应该是两处需要改,即:2605行 2617行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant