Exemplo n.º 1
0
    def test_program_clone_with_parameter(self):
        main_program = Program()
        startup_program = Program()
        kwargs = {
            'main_program': main_program,
            'startup_program': startup_program
        }
        d = layers.data(name='x', shape=[784], dtype='float32', **kwargs)
        hidden = layers.fc(input=d, size=100, **kwargs)
        layers.fc(input=hidden, size=100, **kwargs)

        new_program = main_program.clone()
        self.assertNotEqual(0, len(new_program.blocks[0].all_parameters()))
Exemplo n.º 2
0
    def test_program_clone_with_parameter(self):
        main_program = Program()
        startup_program = Program()
        kwargs = {
            'main_program': main_program,
            'startup_program': startup_program
        }
        d = layers.data(name='x', shape=[784], dtype='float32', **kwargs)
        hidden = layers.fc(input=d, size=100, **kwargs)
        layers.fc(input=hidden, size=100, **kwargs)

        new_program = main_program.clone()
        self.assertNotEqual(0, len(new_program.blocks[0].all_parameters()))
Exemplo n.º 3
0
    def test_program_clone(self):
        prog = Program()

        x = prog.global_block().create_var(
            name='X', shape=[1000, 784], dtype='float32')

        y = prog.global_block().create_var(
            name='Y', shape=[784, 100], dtype='float32')
        out = prog.global_block().create_var(name='Out', dtype='float32')
        prog.global_block().append_op(
            type="mul", inputs={'X': [x],
                                'Y': [y]}, outputs={'Out': [out]})

        # FIXME(yuyang18): We manual compare the output string, since the order
        # of variable could be changed.
        print(prog)
        print(prog.clone())
Exemplo n.º 4
0
    def test_program_clone(self):
        prog = Program()

        x = prog.global_block().create_var(name='X',
                                           shape=[1000, 784],
                                           dtype='float32')

        y = prog.global_block().create_var(name='Y',
                                           shape=[784, 100],
                                           dtype='float32')
        out = prog.global_block().create_var(name='Out', dtype='float32')
        prog.global_block().append_op(type="mul",
                                      inputs={
                                          'X': [x],
                                          'Y': [y]
                                      },
                                      outputs={'Out': [out]})

        # FIXME(yuyang18): We manual compare the output string, since the order
        # of variable could be changed.
        print(prog)
        print(prog.clone())