tensorlayer / TensorLayer

Deep Learning and Reinforcement Learning Library for Scientists and Engineers
http://tensorlayerx.com
Other
7.31k stars 1.61k forks source link

IndexError: list index out of range #1156

Closed jaried closed 2 years ago

jaried commented 2 years ago

New Issue Checklist

Issue Description

IndexError: list index out of range

Reproducible Code

https://github.com/tensorlayer/tensorlayer/blob/master/examples/reinforcement_learning/tutorial_PG.py Because of the previous issue AttributeError: 'str' object has no attribute 'decode' , I modified code of \tensorlayer\files\utils.py, line 2617 to weight_names = [n if isinstance(n, str) else n.decode('utf8') for n in f.attrs["layer_names"]] then :

Traceback (most recent call last):
  File "D:/Tony/Documents/yunpan/invest/2022/quant/gym/study PG/PG/pg.py", line 219, in <module>
    agent.load()
  File "D:/Tony/Documents/yunpan/invest/2022/quant/gym/study PG/PG/pg.py", line 161, in load
    tl.files.load_hdf5_to_weights_in_order(os.path.join(path, 'pg_policy.hdf5'), self.model)
  File "D:\Anaconda3\envs\gym_env\lib\site-packages\tensorlayer\files\utils.py", line 2729, in load_hdf5_to_weights_in_order
    _load_weights_from_hdf5_group_in_order(f, network.all_layers)
  File "D:\Anaconda3\envs\gym_env\lib\site-packages\tensorlayer\files\utils.py", line 2618, in _load_weights_from_hdf5_group_in_order
    assign_tf_variable(layer.all_weights[iid], np.asarray(g[w_name]))
IndexError: list index out of range