Issue
I am trying to combine two ParameterList
s in Pytorch. I've implemented the following snippet:
import torch
list = nn.ParameterList()
for i in sub_list_1:
list.append(i)
for i in sub_list_2:
list.append(i)
Is there any functions that takes care of this without a need to loop over each list?
Solution
You can use nn.ParameterList.extend
, which works like python's built-in list.extend
plist = nn.ParameterList()
plist.extend(sub_list_1)
plist.extend(sub_list_2)
Alternatively, you can use +=
which is just an alias for extend
plist = nn.ParameterList()
plist += sub_list_1
plist += sub_list_2
Answered By - jodag
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.