Пример #1
0
            chosen_edge = chosen_adj_list[chosen_edge]
            edge_number = chosen_edge[0]

        edges[i] = edge_number
        other_vertex = chosen_edge[1]
        picked[edge_number] = True
        sample_counts[chosen_vertex] -= 1
        sample_counts[other_vertex] -= 1
        seen[other_vertex] = True

    return edges


if "NegativeSampleRate" in general_settings:
    ns = auxilliaries.NegativeSampler(
        int(general_settings["NegativeSampleRate"]),
        general_settings["EntityCount"])
    ns.set_known_positives(train_triplets)

    def t_func(x):  # horrible hack!!!
        arr = np.array(x)
        if not encoder.needs_graph():
            return ns.transform(arr)
        else:
            if "GraphBatchSize" in general_settings:
                graph_batch_size = int(general_settings["GraphBatchSize"])
                """
                n = np.zeros(100)
                for i in range(100):
                    if i % 20 == 0:
                        print(i)
Пример #2
0
            chosen_edge = chosen_adj_list[chosen_edge]
            edge_number = chosen_edge[0]

        edges[i] = edge_number
        other_vertex = chosen_edge[1]
        picked[edge_number] = True
        sample_counts[chosen_vertex] -= 1
        sample_counts[other_vertex] -= 1
        seen[other_vertex] = True

    return edges


if 'NegativeSampleRate' in general_settings:
    ns = auxilliaries.NegativeSampler(
        int(general_settings['NegativeSampleRate']),
        general_settings['EntityCount'])
    ns.set_known_positives(train_triplets)

    def t_func(x):  #horrible hack!!!
        arr = np.array(x)
        if not encoder.needs_graph():
            return ns.transform(arr)
        else:
            if 'GraphBatchSize' in general_settings:
                graph_batch_size = int(general_settings['GraphBatchSize'])
                '''
                n = np.zeros(100)
                for i in range(100):
                    if i % 20 == 0:
                        print(i)
Пример #3
0
                    np.arange(chosen_adj_list.shape[0]))
                chosen_edge = chosen_adj_list[chosen_edge]
                edge_number = chosen_edge[0]

            edges[i] = edge_number
            other_vertex = chosen_edge[1]
            picked[edge_number] = True
            sample_counts[chosen_vertex] -= 1
            sample_counts[other_vertex] -= 1
            seen[other_vertex] = True

        return edges

    if 'NegativeSampleRate' in general_settings:
        ns = auxilliaries.NegativeSampler(
            float(general_settings['NegativeSampleRate']),
            general_settings['EntityCount'], entities.values())
        ns.set_positives(train_triplets)

        def t_func(x):
            arr = np.array(x)
            if not encoder.needs_graph():
                return ns.transform(arr)
            else:
                graph_batch_size = int(general_settings['GraphBatchSize'])
                graph_batch_ids = sample_edge_neighborhood(
                    arr, graph_batch_size)
                graph_batch = train_triplets[graph_batch_ids]

                # Apply dropouts:
                graph_percentage = float(general_settings['GraphSplitSize'])