This is probably a basic python question but it is one of those things that I can’t seem to let go and can’t find an answer to.
In the first class, when Vgg16 is instatiated by vgg = Vgg16(), this runs with no problem so I am not questioning the code.
But in trying to understand the code, there is this line:
…
def init(self):
self.FILE_PATH = 'http://files.fast.ai/models/'
self.create()
self.get_classes()
…
def create(self):
model = self.model = Sequential()
model.add(Lambda(vgg_preprocess, input_shape=(3,224,224), output_shape=(3,224,224)))
self.ConvBlock(2, 64)
self.ConvBlock(2, 128)
So I am assuming the changes to model are changes in self.model, i.e. they refer to the same thing as in:
class g():
def init(self):
m=self.m=6
print self.m, m
print self.m is m
h = g()
6 6
True
But when I modify m by itself, this changes:
class g():
def init(self):
m=self.m=6
m += 5
print self.m, m
print self.m is m
h = g()
6 11
False
I am confused about why changes to model are reflected in self.model and vice versa.
THanks
Johnn