def test_repeat_block_sequence(self): Dense('256', input_shape='784').b(self.b1).run() Dropout('0.5').run() RepeatBegin().b(self.b2).run() Dense('128', activation='relu').b(self.b1).run() Dropout('0.2').run() Dense('128', activation='sigmoid').run() Dropout('0.8').run() RepeatEnd(self.b2, '2').run() Dense('10', activation='softmax').run() SummaryLayer(self.b1).run()
def build_model(): m = MODEL_BRANCH # build model InputLayer('784').b(m).run() Dense('512', activation='relu').run() # Dense('512', activation='relu', input_shape='784').b(m).run() Dropout('0.2').run() Dense('512', activation='relu').run() Dropout('0.2').run() Dense('10', activation='softmax').run() # compile model Compile('categorical_crossentropy', 'rmsprop', ['accuracy']).run() # show network struct SummaryLayer(m).run()
def setUp(self) -> None: n1 = BRANCH_1 n2 = BRANCH_2 # first branch InputLayer('784').b(n1).run() Dense('256').run() Dropout('0.5').run() Dense('64').run() Dropout('0.2').run() # second branch InputLayer('256').b(n2).run() Dense('64').run() Dropout('0.5').run()
def test_repeat_block_network_branch(self): # TODO 暂不兼容复用分支快包含多分支类型 InputLayer(input_shape='784').b(self.b1).run() Dense('256').run() Dropout('0.5').run() RepeatBegin().b(self.b2).run() Dense('128', activation='relu').b(self.b3).run() Dropout('0.2').run() Dense('128', activation='sigmoid').b(self.b4).run() Dropout('0.8').run() Add(input_branch_1=self.b3, input_branch_2=self.b4).b(self.b1).run() RepeatEnd(self.b2, '2').run() Dense('10', activation='softmax').run() SummaryLayer(self.b1).run()
def test_repeat_branch(self): # branch Dense('256').b(self.b1).run() Dropout('0.5').run() Dense('64').run() # main Branch InputLayer(input_shape='784').b(self.b2).run() Dense('256').run() Dropout('0.5').run() Dense('128').run() RepeatBranch(self.b1, '2').run() Dense('10', activation='softmax').run() SummaryLayer(self.b2).run()
def test_repeat_branch_multi_branch(self): # TODO 暂不兼容复用分支快包含多分支类型 # branch Dense('256').b(self.b1).run() Dropout('0.5').run() Dense('64').b(self.b2).run() Dropout('0.5').run() Dense('64').b(self.b1).run() Dropout('0.5').run() Add(input_branch_1=self.b1, input_branch_2=self.b2).run() # main Branch InputLayer(input_shape='784').b(self.b2).run() Dense('256').run() Dropout('0.5').run() Dense('128').run() RepeatBranch(self.b1, '2').run() Dense('10', activation='softmax').run() SummaryLayer(self.b2).run()