Пример #1
0
    def testFullTraining(self):
        filename = "iris_tests/full_iris.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        data_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "iris_tests")
        self.setup_holder.variable_repository.set_variable_value(
            "data_folder", data_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "adam_upd"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        update = adder.get_out_socket("update")

        component_spec = CreationComponentSpecifications()
        component_spec.name = "cross_ent"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        loss = adder.get_out_socket("output")

        component_spec = CreationComponentSpecifications()
        component_spec.name = "accuracy"
        component = self.setup_holder.component_repository.get(
            component_spec)[0]
        accuracy = component.get_out_socket("output")

        ml_helper = self.setup_holder.ml_helper_factory.build_ml_helper(
            update=update, loss=loss, evaluate=accuracy)

        ml_helper.train()
        performance = ml_helper.evaluate()

        self.assertGreaterEqual(1.0, performance)
        self.assertLess(0.9, performance)
Пример #2
0
    def testLoadsLanguagesCorrect(self):
        component_type_spec = ComponentTypeSpecifications()
        component_type_spec.name = "Constant"
        component_type = self.setup_holder.type_repository.create(
            component_type_spec)
        component_type.out_sockets = ["output"]
        component_type.languages = ["test_language"]

        component_type_spec = ComponentTypeSpecifications()
        component_type_spec.name = "Add"
        component_type = self.setup_holder.type_repository.create(
            component_type_spec)
        component_type.in_sockets = ["left", "right"]
        component_type.languages = ["tensorflow", "python"]

        filename = "add_constants.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        spec = CreationComponentSpecifications()
        spec.name = "constant_1"
        component = self.setup_holder.component_repository.get(spec)[0]
        self.assertEqual("test_language", component.language)

        spec = CreationComponentSpecifications()
        spec.name = "adder"
        component = self.setup_holder.component_repository.get(spec)[0]
        self.assertEqual("python", component.language)
Пример #3
0
    def testLoadsSimpleCanvasWithTwoComponents(self):
        component_type_spec = ComponentTypeSpecifications()
        component_type_spec.name = "Constant"
        component_type = self.setup_holder.type_repository.create(
            component_type_spec)

        def test_assign(dic):
            dic["value"] = "test_value"
            dic["value_type"] = "test_value"

        component_type.assign_default_value = test_assign

        text = """<canvas name="main">
        <component name="constant_1" type="Constant"><value>5.17</value><type>float</type></component>
        <component name="constant_2" type="Constant"><value>8.14</value><type>float</type></component>
        </canvas>"""

        self.setup_holder.canvas_loader.load_canvas(text, 0)

        self.assertEqual(1, self.setup_holder.canvas_repository.count())
        self.assertEqual(2, self.setup_holder.component_repository.count())

        canvas_spec = CanvasSpecifications()
        canvas_spec.name = "main"
        canvases = self.setup_holder.canvas_repository.get(canvas_spec)

        self.assertEqual(1, len(canvases))
        self.assertEqual("main", canvases[0].name)
        self.assertEqual(2, canvases[0].count_components())

        spec = CreationComponentSpecifications()
        spec.name = "constant_1"

        components = self.setup_holder.component_repository.get(spec)

        self.assertEqual(1, len(components))
        self.assertEqual("constant_1", components[0].name)
        self.assertEqual("Constant", components[0].get_component_type_name())
        self.assertEqual([("5.17", {})],
                         components[0].get_value_dictionary()["value"])
        self.assertEqual([("float", {})],
                         components[0].get_value_dictionary()["type"])
        self.assertEqual(canvases[0], components[0].canvas)

        spec.name = "constant_2"

        components = self.setup_holder.component_repository.get(spec)

        self.assertEqual(1, len(components))
        self.assertEqual("constant_2", components[0].name)
        self.assertEqual("Constant", components[0].get_component_type_name())
        self.assertEqual([("8.14", {})],
                         components[0].get_value_dictionary()["value"])
        self.assertEqual([("float", {})],
                         components[0].get_value_dictionary()["type"])
        self.assertEqual(canvases[0], components[0].canvas)
    def testGetByName(self):
        specs = CreationComponentSpecifications()
        specs.name = "testComponent"

        element_1 = self.repository.create(specs)
        element_retrieved = self.repository.get(specs)

        self.assertEqual(1, len(element_retrieved))
        self.assertEqual(element_1.identifier, element_retrieved[0].identifier)
        self.assertEqual(element_1, element_retrieved[0])

        specs.name = "falseTestName"

        element_retrieved = self.repository.get(specs)
        self.assertEqual(0, len(element_retrieved))
Пример #5
0
    def testEmbeddingLookup(self):
        filename = "conll_reader_tests/embedding_lookup.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(filename)
        self.setup_holder.block_loader.load(filepath)

        conll_filepath = self.setup_holder.filepath_handler.get_test_block_path("conll_reader_tests/test_conll_file.conll")
        self.setup_holder.variable_repository.set_variable_value("data_file", conll_filepath)

        embedding_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "conll_reader_tests/test_embeddings.txt")
        self.setup_holder.variable_repository.set_variable_value("embedding_file", embedding_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "embedding_lookup"
        target = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = target.get_out_socket("output")

        runs = [[target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)

        self.setup_holder.initialization_helper.initialize(run_graphs)

        results = run_graphs[0].execute()[0]
        self.assertEqual(2, len(results))

        self.assertEqual(5, len(results[0]))
        self.assertEqual(4, len(results[1]))

        for r in results[0]:
            self.assertEqual(3, len(r))

        for r in results[1]:
            self.assertEqual(3, len(r))
Пример #6
0
    def testEmbeddingIndexing(self):
        filename = "conll_reader_tests/embedding_index.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(filename)
        self.setup_holder.block_loader.load(filepath)

        conll_filepath = self.setup_holder.filepath_handler.get_test_block_path("conll_reader_tests/test_conll_file.conll")
        self.setup_holder.variable_repository.set_variable_value("data_file", conll_filepath)

        embedding_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "conll_reader_tests/test_embeddings.txt")
        self.setup_holder.variable_repository.set_variable_value("embedding_file", embedding_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "indexer"
        target = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = target.get_out_socket("output")

        runs = [[target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)

        self.assertEqual(1, len(run_graphs))

        self.assertEqual([[[0,1,2,3,4],
                          [5,1,0,4]]], run_graphs[0].execute())
Пример #7
0
    def testDeIndexer(self):
        filename = "conll_reader_tests/conll_reader_with_indexer.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(filename)
        self.setup_holder.block_loader.load(filepath)
        conll_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "conll_reader_tests/test_conll_file.conll")
        self.setup_holder.variable_repository.set_variable_value("data_file", conll_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "deindexer"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = adder.get_out_socket("output")

        runs = [[target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)

        self.assertEqual(1, len(run_graphs))
        results = run_graphs[0].execute()
        self.assertEqual([[["this",
                           "is",
                           "a",
                           "sentence",
                           "."],
                          ["so",
                           "is",
                           "this",
                           "."]]], results)
Пример #8
0
    def testAccuracyOnly(self):
        filename = "iris_tests/untrained_iris_accuracy.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        data_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "iris_tests")
        self.setup_holder.variable_repository.set_variable_value(
            "data_folder", data_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "accuracy"
        component = self.setup_holder.component_repository.get(
            component_spec)[0]
        accuracy = component.get_out_socket("output")

        ml_helper = self.setup_holder.ml_helper_factory.build_ml_helper(
            evaluate=accuracy)

        performance = ml_helper.evaluate()

        self.assertGreaterEqual(1.0, performance)
        self.assertLessEqual(0.0, performance)
        self.assertFalse(ml_helper.evaluate_function.has_batches("test"))
Пример #9
0
    def testAccuracyOnlyWithoutMlHelper(self):
        filename = "iris_tests/untrained_iris_accuracy.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        data_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "iris_tests")
        self.setup_holder.variable_repository.set_variable_value(
            "data_folder", data_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "accuracy"
        component = self.setup_holder.component_repository.get(
            component_spec)[0]
        accuracy = component.get_out_socket("output")

        runs = [[accuracy]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        self.setup_holder.initialization_helper.initialize(run_graphs)
        run_graphs[0].init_batches()
        performance = sum(run_graphs[0].execute()[0])

        self.assertGreaterEqual(10.0, performance)
        self.assertLessEqual(0.0, performance)
Пример #10
0
    def testTileDuplicatesProperly(self):
        #TODO: Move to separate file
        filename = "iris_tests/batch_and_tile_iris.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        data_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "iris_tests")
        self.setup_holder.variable_repository.set_variable_value(
            "data_folder", data_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "tile"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket_1 = adder.get_out_socket("output")

        runs = [[target_socket_1]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        result = run_graphs[0].execute()[0]

        self.assertEqual(100, len(result))
        self.assertEqual(25, len(result[0]))

        for i in range(50):
            self.assertEqual(result[i * 2], result[i * 2 + 1])

        for i in range(5):
            for j in range(4):
                self.assertEqual(result[0][i * 5], result[0][i * 5 + j + 1])
Пример #11
0
    def testLoadsSimpleCanvasWithEdge(self):
        component_type_spec = ComponentTypeSpecifications()
        component_type_spec.name = "Constant"
        component_type = self.setup_holder.type_repository.create(
            component_type_spec)
        component_type.out_sockets = ["out"]

        component_type_spec = ComponentTypeSpecifications()
        component_type_spec.name = "Printer"
        component_type = self.setup_holder.type_repository.create(
            component_type_spec)
        component_type.in_sockets = ["in"]

        text = """<canvas name="main">
        <component name="constant_1" type="Constant"></component>
        <component name="printer" type="Printer"></component>
        <edge><source socket=out>constant_1</source><target socket=in>printer</target></edge>
        </canvas>"""

        self.setup_holder.canvas_loader.load_canvas(text, 0)

        spec = CreationComponentSpecifications()
        spec.name = "constant_1"
        components = self.setup_holder.component_repository.get(spec)
        graph = components[0].graph

        self.assertEqual(1, len(graph.get_edges()))
        self.assertEqual(2, len(graph.get_vertices()))

        edge = graph.get_edges()[0]
        self.assertEqual("constant_1", edge.get_source_component_name())
        self.assertEqual("printer", edge.get_target_component_name())
Пример #12
0
    def testLoadsFullBlockTwoCanvases(self):
        component_type_spec = ComponentTypeSpecifications()
        component_type_spec.name = "Constant"
        component_type = self.setup_holder.type_repository.create(
            component_type_spec)
        component_type.out_sockets = ["out"]

        component_type_spec = ComponentTypeSpecifications()
        component_type_spec.name = "Printer"
        component_type = self.setup_holder.type_repository.create(
            component_type_spec)
        component_type.in_sockets = ["in"]

        text = """<block>
        <canvas name="main">
        <component name="constant_1" type="Constant"></component>
        <component name="printer" type="Printer"></component>
        <edge><source socket=out>constant_1</source><target socket=in>printer</target></edge>
        </canvas>
        <canvas name="secondary">
        <component name="constant_1_s" type="Constant"></component>
        <component name="printer_s" type="Printer"></component>
        <edge><source socket=out>constant_1_s</source><target socket=in>printer_s</target></edge>
        </canvas>
        </block>"""

        self.setup_holder.block_loader.load_block(text, 0)

        self.assertEqual(2, self.setup_holder.canvas_repository.count())

        spec = CreationComponentSpecifications()
        spec.name = "constant_1"
        component = self.setup_holder.component_repository.get(spec)[0]
        self.assertEqual("main", component.canvas.name)

        spec = CreationComponentSpecifications()
        spec.name = "constant_1_s"
        component = self.setup_holder.component_repository.get(spec)[0]
        self.assertEqual("secondary", component.canvas.name)
Пример #13
0
    def testExecutesMultipleTargetsInRun(self):
        filename = "add_constants_with_extra_adder.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "adder"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = adder.get_out_socket("output")

        component_spec.name = "adder_2"
        adder_2 = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket_2 = adder_2.get_out_socket("output")

        runs = [[target_socket, target_socket_2]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        self.setup_holder.initialization_helper.initialize(run_graphs)

        self.assertEqual(1, len(run_graphs))
        self.assertEqual([8.15, 13.32], run_graphs[0].execute())
Пример #14
0
    def testIntegratedBatches(self):
        filename = "iris_tests/integrated_batch_iris.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        data_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "iris_tests")
        self.setup_holder.variable_repository.set_variable_value(
            "data_folder", data_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "data_splitter"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket_1 = adder.get_out_socket("left")

        runs = [[target_socket_1]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        run_graphs[0].init_batches()

        result = run_graphs[0].execute()[0]
        self.assertTrue(run_graphs[0].has_batches("test"))
        self.assertEqual(40, len(result))
        result = run_graphs[0].execute()[0]
        self.assertTrue(run_graphs[0].has_batches("test"))
        self.assertEqual(40, len(result))
        result = run_graphs[0].execute()[0]
        self.assertTrue(run_graphs[0].has_batches("test"))
        self.assertEqual(40, len(result))
        result = run_graphs[0].execute()[0]
        self.assertEqual(30, len(result))
        self.assertFalse(run_graphs[0].has_batches("test"))

        run_graphs[0].init_batches()

        result = run_graphs[0].execute()[0]
        self.assertTrue(run_graphs[0].has_batches("test"))
        self.assertEqual(40, len(result))
        result = run_graphs[0].execute()[0]
        self.assertTrue(run_graphs[0].has_batches("test"))
        self.assertEqual(40, len(result))
        result = run_graphs[0].execute()[0]
        self.assertTrue(run_graphs[0].has_batches("test"))
        self.assertEqual(40, len(result))
        result = run_graphs[0].execute()[0]
        self.assertEqual(30, len(result))
        self.assertFalse(run_graphs[0].has_batches("test"))
Пример #15
0
    def testSecondLadderAdd(self):
        filename = "tensorflow_unit_test_blocks/ladder_add_tensorflow_2.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(filename)
        self.setup_holder.block_loader.load(filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "adder_3"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = adder.get_out_socket("output")

        runs = [[target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        self.setup_holder.initialization_helper.initialize(run_graphs)

        self.assertEqual(1, len(run_graphs))
        self.assertAlmostEqual(8.0, run_graphs[0].execute()[0], places=5)
Пример #16
0
    def testMultiplyByAdding(self):
        filename = "multiply_by_adding.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "adder_3"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = adder.get_out_socket("output")

        runs = [[target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)

        self.assertEqual(1, len(run_graphs))
        self.assertEqual([12.4], run_graphs[0].execute())
Пример #17
0
    def testCreatesExecutionGraphs(self):
        filename = "add_constants.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "adder"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = adder.get_out_socket("output")

        runs = [[target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        self.setup_holder.initialization_helper.initialize(run_graphs)

        self.assertEqual(1, len(run_graphs))
        self.assertEqual([8.15], run_graphs[0].execute())
Пример #18
0
    def testModeSplitOnlyUsedPartsPulled(self):
        filename = "mode_pull_constants.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "mode_split"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = adder.get_out_socket("output")

        runs = [[target_socket], [target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(
            runs, run_modes=["train", "test"])

        self.assertEqual(2, len(run_graphs[0].get_components()))
        self.assertEqual(2, len(run_graphs[1].get_components()))
Пример #19
0
    def testAdderWithVariable(self):
        filename = "add_constants_with_variable.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "adder"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket = adder.get_out_socket("output")

        runs = [[target_socket], [target_socket]]
        run_modes = ["train", "test"]

        run_graphs = self.setup_holder.graph_converter.to_executable(
            runs, run_modes=run_modes)

        self.assertEqual(2, len(run_graphs))
        self.assertEqual([8.15], run_graphs[0].execute())
        self.assertEqual([13.15], run_graphs[1].execute())
Пример #20
0
    def testCellSanity(self):
        filename = "seq_to_seq_tests/repeat_rnn_cell_sanity.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "cell"
        target_c = self.setup_holder.component_repository.get(
            component_spec)[0]

        target_socket = target_c.get_out_socket("output")

        runs = [[target_socket]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)

        self.assertEqual(1, len(run_graphs))
        output = run_graphs[0].execute()[0]
        self.assertEqual(5.17, output[0])
        self.assertEqual(2.98, output[1])
Пример #21
0
    def testIndexesNames(self):
        filename = "iris_tests/read_and_index_iris_data.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        data_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "iris_tests")
        self.setup_holder.variable_repository.set_variable_value(
            "data_folder", data_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "indexer"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket_1 = adder.get_out_socket("output")

        runs = [[target_socket_1]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        result = run_graphs[0].execute()

        self.assertEqual(0, result[0][0])
        self.assertEqual(1, result[0][50])
        self.assertEqual(2, result[0][100])
Пример #22
0
    def testReadsDataListReader(self):
        filename = "iris_tests/read_iris_data_list_reader.xml"
        filepath = self.setup_holder.filepath_handler.get_test_block_path(
            filename)
        self.setup_holder.block_loader.load(filepath)

        data_filepath = self.setup_holder.filepath_handler.get_test_block_path(
            "iris_tests")
        self.setup_holder.variable_repository.set_variable_value(
            "data_folder", data_filepath)

        component_spec = CreationComponentSpecifications()
        component_spec.name = "data_splitter"
        adder = self.setup_holder.component_repository.get(component_spec)[0]
        target_socket_1 = adder.get_out_socket("left")
        target_socket_2 = adder.get_out_socket("right")

        runs = [[target_socket_1, target_socket_2]]

        run_graphs = self.setup_holder.graph_converter.to_executable(runs)
        result = run_graphs[0].execute()

        self.assertEqual("0.2", result[0][0][-1])
        self.assertEqual("Iris-setosa", result[1][0][0])
Пример #23
0
    def load_edge(self, text, start_index, graph_id=None):
        next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=start_index)

        if next_symbol != "edge":
            print("ERROR")
            exit()

        source_socket = None
        target_socket = None

        cast = None
        if "cast" in attributes:
            cast = attributes["cast"]

        dropout_rate = None

        while next_symbol != "/edge":
            next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=pointer)
            if next_symbol == "source":
                socket_name = attributes["socket"]
                next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=pointer)

                component_name = next_symbol
                component_spec = CreationComponentSpecifications()
                component_spec.graph_id = graph_id
                component_spec.name = component_name
                components = self.component_repository.get(component_spec)

                if len(components) == 0:
                    raise ComponentNotFoundException("Attempted edge creation with undeclared source component " + component_name)

                component = components[0]

                try:
                    source_socket = component.get_out_socket(socket_name)
                except SocketNotFoundException:
                    raise SocketNotFoundException("Attempted edge creation with non-existant socket "+socket_name+" for source component "+component_name)

                next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=pointer)
            elif next_symbol == "target":
                socket_name = attributes["socket"]
                next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=pointer)

                component_name = next_symbol
                component_spec = CreationComponentSpecifications()
                component_spec.graph_id = graph_id
                component_spec.name = component_name
                components = self.component_repository.get(component_spec)

                if len(components) == 0:
                    raise ComponentNotFoundException("Attempted edge creation with undeclared target component " + component_name)

                component = components[0]

                try:
                    target_socket = component.get_in_socket(socket_name)
                except SocketNotFoundException:
                    raise SocketNotFoundException("Attempted edge creation with non-existant socket "+socket_name+" for target component "+component_name)

                next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=pointer)
            elif next_symbol == "dropout":
                dropout_attributes = attributes
                next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=pointer)
                dropout_rate = next_symbol
                next_symbol, attributes, pointer = self.xml_helper.pop_symbol(text, start_index=pointer)

        edge = self.graph_repository.add_edge(source_socket, target_socket)

        if dropout_rate is not None:
            edge.add_value_line("dropout_rate", (dropout_rate, dropout_attributes))

        if cast is not None:
            edge.add_value_line("cast", (cast, {}))

        return edge, pointer