def test_training_property(): import nnabla.parametric_functions as PF class ConvBn(nn.Module): def call(self, x): h = PF.convolution(x, 3, (3, 2)) return h model = ConvBn() x = nn.Variable((64, 3, 32, 32)) y = model(x) model.training = True assert model.training == True
def call(self, x1, x2): y1 = self.conv_bn_1(x1) y2 = self.conv_bn_2(x2) y = F.concatenate(y1, y2, axis=1) # ConvBn() will be destroyed when leave this scope. # Thus, the parameters owned by `cb` object will be released too. cb = ConvBn(1) y = F.concatenate(y, cb(x1), axis=1) return y
def __init__(self): self.conv_bn_1 = ConvBn(1) self.conv_bn_2 = ConvBn(1)
def __init__(self): self.conv_bn = ConvBn(3)
def __init__(self): self.cb = ConvBn(2) self.cb2 = ConvBn(2) self.shared1 = Shared(self.cb2) self.shared2 = Shared(self.cb2)