Пример #1
0
 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()
Пример #2
0
 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()
Пример #3
0
    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()
Пример #4
0
 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()
Пример #5
0
    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()
Пример #6
0
 def test_relu(self):
     InputLayer('784').run()
     Dense('512').run()
     ReLU(max_value='', negative_slope='0', threshold='0').run()
     ReLU(max_value='', negative_slope='0', threshold='0').run()
     ReLU(max_value='', negative_slope='0', threshold='0').run()
     SummaryLayer().run()
Пример #7
0
 def test_softmax(self):
     InputLayer('784').run()
     Dense('512').run()
     Softmax(axis='-1').run()
     Softmax(axis='-1').run()
     Softmax(axis='-1').run()
     SummaryLayer().run()
Пример #8
0
 def test_thresholded_relu(self):
     InputLayer('784').run()
     Dense('512').run()
     ThresholdedReLU(theta='1.0').run()
     ThresholdedReLU(theta='1.0').run()
     ThresholdedReLU(theta='1.0').run()
     SummaryLayer().run()
Пример #9
0
 def test_elu(self):
     InputLayer('784').run()
     Dense('512').run()
     ELU(alpha='1.0').run()
     ELU(alpha='1.0').run()
     ELU(alpha='1.0').run()
     SummaryLayer().run()
Пример #10
0
 def test_prelu(self):
     InputLayer('784').run()
     Dense('512').run()
     PReLU(alpha_initializer='zeros').run()
     PReLU(alpha_initializer='zeros').run()
     PReLU(alpha_initializer='zeros').run()
     SummaryLayer().run()
Пример #11
0
 def test_leaky_relu(self):
     InputLayer('784').run()
     Dense('512').run()
     LeakyReLU(alpha='0.3').run()
     LeakyReLU(alpha='0.3').run()
     LeakyReLU(alpha='0.3').run()
     SummaryLayer().run()
Пример #12
0
    def test_compile_advanced(self):
        # model
        SGD(lr='0.25').b(0).run()

        InputLayer('784').b(1).run()
        Dense('512').run()

        CompileAdvanced(0, 'categorical_crossentropy', ['accuracy']).run()
        rdd = inputRDD(1)
        rdd.show()
        print(json.dumps(json.loads(rdd.first().compile_config), indent=4))
        print(json.dumps(json.loads(rdd.first().model_config), indent=4))
Пример #13
0
    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()
Пример #14
0
 def test_compile(self):
     InputLayer('784').run()
     Dense('512').run()
     Compile('categorical_crossentropy', 'rmsprop', ['accuracy']).run()
     inputRDD(BRANCH).show()