python - I need to understand how __setstate__ can change the value of assigned variable -
this part of code show how code constructed. after calling , initiating network call function setstate update saved parameters iterate , save them in self.params update done inside object layer , variables w , b.
i don't understand how updating self.params update original variables.
def __getstate__(self): weights = [p.get_value() p in self.params] return weights def __setstate__(self, weights): = iter(weights) p in self.params: p.set_value(i.next()) def __init__(self, .......): self.layer8 = lenetconvpoollayer( rng, input=self.layer7.output, image_shape=(.....), filter_shape=(....), subsample=(..) ) self.params = self.layer8.params + self.layer7.params + self.layer6.params class lenetconvpoollayer(object): def __init__(self, .......): self.w = theano.shared(w_values, borrow=true ) self.b = theano.shared(value=b_values, borrow=true) self.params = [self.w, self.b]
Comments
Post a Comment