I have a generator and I want to modify the last element of the generator. I want to replace the last element with another element. I know how to retrieve the last element, but not how to modify it.
What would be the best way to approach this?
For more context, this is what I want to do:
for child in alexnet.children():
for children_of_child in child.children():
print(children_of_child);
My generator object is: children_of_child
and for the second child all its children are:
Dropout(p=0.5)
Linear(in_features=9216, out_features=4096, bias=True)
ReLU(inplace)
Dropout(p=0.5)
Linear(in_features=4096, out_features=4096, bias=True)
ReLU(inplace)
Linear(in_features=4096, out_features=1000, bias=True)
I want to replace the last layer Linear(in_features=4096, out_features=1000, bias=True)
with my own regression net. `