コード例 #1
0
ファイル: solo_window.py プロジェクト: boxspah/MAL-groupwatch
 def get_values(self) -> None:
     """Get values from user input (combo boxes and spin boxes)"""
     graph = load_graph("data/rating.csv", "data/anime.csv")
     vals_so_far = []
     vals_so_far.append((self.cbox1.currentText(), self.spin_box.value()))
     vals_so_far.append((self.cbox2.currentText(), self.sbox2.value()))
     vals_so_far.append((self.cbox3.currentText(), self.sbox3.value()))
     vals_so_far.append((self.cbox4.currentText(), self.sbox4.value()))
     vals_so_far.append((self.cbox5.currentText(), self.sbox5.value()))
     vals_so_far.append((self.cbox6.currentText(), self.sbox6.value()))
     vals_so_far.append((self.cbox7.currentText(), self.sbox7.value()))
     vals_so_far.append((self.cbox8.currentText(), self.sbox8.value()))
     vals_so_far.append((self.cbox9.currentText(), self.sbox9.value()))
     vals_so_far.append((self.cbox10.currentText(), self.sbox10.value()))
     vals_so_far = [val for val in vals_so_far if val[0] != 'None']
     graph.add_vertex('user1', 'user')
     for val3 in vals_so_far:
         graph.add_vertex(val3[0], 'anime')
         graph.add_edge('user1', val3[0], val3[1])
     recommendations = recommend_animes(vals_so_far, 10, graph, 'pearson')
     self.window = QtWidgets.QWidget()
     self.ui = UiForm(recommendations)
     self.ui.setup_ui(self.window)
     self.widget.addWidget(self.window)
     self.widget.setCurrentIndex(self.widget.currentIndex() + 1)
コード例 #2
0
    def restore_model(self):
        print("Restoring saved model...")
        '''
        # 1
        self.sess = tf.Session() 

        model_meta_file = self.model_var_dir + '/saved_model.meta'

        new_saver = tf.train.import_meta_graph(model_meta_file)
        new_saver.restore(self.sess, tf.train.latest_checkpoint(self.model_var_dir))
        
        all_vars = tf.get_collection('vars')
        for v in all_vars:
            v_ = sess.run(v)
            print(v_)
        
        graph = tf.get_default_graph()
        self.keep_prob   = graph.get_tensor_by_name('keep_prob:0')
        self.input_image = graph.get_tensor_by_name('image_input:0')
        self.logits      = graph.get_tensor_by_name('logits:0')
        '''

        # 2
        graph_filename = "models/100-Epochs-roborace350/optimized_graph.pb"
        graph, ops = load_graph(graph_filename, True)
        self.keep_prob = graph.get_tensor_by_name('keep_prob:0')
        self.input_image = graph.get_tensor_by_name('image_input:0')
        self.logits = graph.get_tensor_by_name('logits:0')
        self.graph = graph

        print("Model successfully restored")
コード例 #3
0
def get_all_graph():
    all_graph_path = os.path.join(os.getcwd(), 'export', 'all_graph.json')
    if not os.path.exists(all_graph_path):
        print('The all_graph is not exist,generating...')
        graph = graph_generation()
    else:
        print('The all_graph is existing, loading...')
        graph = load_graph('all_graph')
    return graph
コード例 #4
0
ファイル: map_plot.py プロジェクト: xrzhuang/campusmap
def map_plot():
    # create a vertex dictionary from load_graph function
    vertex_dict = load_graph("dartmouth_graph.txt")

    # initialize start_search variable
    start_search = None

    # loop when window isn't closed
    while not window_closed():

        # load map
        img = load_image("dartmouth_map.png")
        draw_image(img, X_MAP, Y_MAP)

        # initialize goal_search
        goal_search = None

        # for loop to draw vertices and edges on map
        for key in vertex_dict:
            vertex_dict[key].draw_vertex(NO_COLOR, COLOR, COLOR)
            vertex_dict[key].edges(NO_COLOR, COLOR, COLOR)

        # if statement when mouse is clocked
        if mouse_down():
            down_x = mouse_x()
            down_y = mouse_y()

            # for loop to find vertex clicked on, set start_search
            for key in vertex_dict:
                if vertex_dict[key].mouse_on(down_x, down_y) == True:
                    start_search = vertex_dict[key]

        # find the hovering vertex, set goal_search
        elif start_search != None:
            for key in vertex_dict:
                if vertex_dict[key].mouse_on(mouse_x(), mouse_y()) == True:
                    if start_search != vertex_dict[key]:
                        goal_search = vertex_dict[key]

        # if start_search, goal_search is set, draw the vertex
        if start_search != None:
            start_search.draw_vertex(COLOR, NO_COLOR, COLOR)
        if goal_search != None:
            goal_search.draw_vertex(COLOR, NO_COLOR, COLOR)

        # if a path is asked to be found, start and goal are set, use bfs, draw and color path
        if start_search != None and goal_search != None:
            path = breadth_first_search(start_search, goal_search)
            for i in range(
                    len(path) - 1
            ):  # - 1 necessary so you don't ask to draw out of index within loop below
                path[i].connect_vertices(path[i + 1], COLOR, NO_COLOR, COLOR)
                path[i].draw_vertex(COLOR, NO_COLOR, COLOR)

        # graphics
        request_redraw()
        sleep(SLEEP_TIME)
コード例 #5
0
ファイル: map_plot.py プロジェクト: hardlyHacking/cs1
def main():
    # Start and goal vertices for BFS.
    start = None
    goal = None

    vertex_dict = load_graph("dartmouth_graph.txt")  # dictionary of vertices
    image = load_image("dartmouth_map.png")  # image of map_plot

    enable_smoothing()

    while not window_closed():
        draw_image(image, 0, 0)  # draw the map

        # Draw each vertex and the edges between each vertex and its neighbors.
        for key in vertex_dict:
            vertex_dict[key].draw_neighbor_edges(0, 0, 1)  # draw in blue
            vertex_dict[key].draw(0, 0, 1)

        # Find a vertex near the current mouse location.
        found = None
        for key in vertex_dict:
            if vertex_dict[key].is_point_near_vertex(mouse_x(), mouse_y()):
                found = vertex_dict[key]
                break  # we've found the vertex, so we don't need to keep going through the loop

        # If the mouse button is down, change the start vertex to whatever is found;
        # could be None.
        if mouse_down():
            start = found

        # If the start vertex has a value other than None, draw it in red, and set the goal.
        # The goal could be None.
        if start != None:
            start.draw(1, 0, 0)  # draw in red
            goal = found

        if start != None and goal != None:  # we have a genuine search!
            path = bfs(start, goal)

            # Draw the path from the goal back to the start in blue.
            previous = goal
            for vertex in path:
                vertex.draw(1, 0, 0)
                vertex.draw_edge(previous, 1, 0, 0)
                previous = vertex

            # Show the names of the start and goal vertices in purple.
            # (Extra-credit feature.)
            start.show_name(0.5, 0, 1)
            goal.show_name(0.5, 0, 1)

        request_redraw()
        sleep(.02)
コード例 #6
0
ファイル: demo.py プロジェクト: jz685/MEngProj
def demo(dname, Ncheb = 1000, Nbin = 50):
	
	## Calling loadgraph and set timer 1
	with MyTimer('Timer One'):
		A, mylambda = load_graph(dname)
		N = nadjacency(A)

	## Calculate cheb moments and set timer 2
	with MyTimer('Timer Two'):
		c = moments_cheb(N, Ncheb, 10)

	## Compare the resuts and display plot, notice filtered cheb moments are passed 
	compare_chebhist(dname, mylambda, filter_jackson(c), Nbin)
コード例 #7
0
def generateCheb(dname, Ncheb = 1000, Nbin = 50):
	
	## Calling loadgraph and set timer 1
	with MyTimer('Timer One'):
		A, mylambda = load_graph(dname)
		N = nadjacency(A)

		c = moments_cheb(N, Ncheb, 10)
		cheb_file_content = '\n'.join([str(st) for st in c])

		cheb_filename = 'data/' + dname + '.cheb'
		f = open(cheb_filename, 'w+')
		f.write(cheb_file_content)
		f.close()
コード例 #8
0
 def get_values(self) -> None:
     """Get values from user input (combo boxes and spin boxes)"""
     graph = load_graph("data/rating.csv", "data/anime.csv")
     vals_so_far1 = []
     vals_so_far2 = []
     vals_so_far1.append((self.cbox1.currentText(), self.spin_box.value()))
     vals_so_far1.append((self.cbox2.currentText(), self.sbox2.value()))
     vals_so_far1.append((self.cbox3.currentText(), self.sbox3.value()))
     vals_so_far1.append((self.cbox4.currentText(), self.sbox4.value()))
     vals_so_far1.append((self.cbox5.currentText(), self.sbox5.value()))
     vals_so_far2.append((self.cbox6.currentText(), self.sbox6.value()))
     vals_so_far2.append((self.cbox7.currentText(), self.sbox7.value()))
     vals_so_far2.append((self.cbox8.currentText(), self.sbox8.value()))
     vals_so_far2.append((self.cbox9.currentText(), self.sbox9.value()))
     vals_so_far2.append((self.cbox10.currentText(), self.sbox10.value()))
     vals_so_far1 = [val for val in vals_so_far1 if val[0] != 'None']
     vals_so_far2 = [val2 for val2 in vals_so_far2 if val2[0] != 'None']
     graph.add_vertex('user1', 'user')
     graph.add_vertex('user2', 'user')
     for val3 in vals_so_far1:
         graph.add_vertex(val3[0], 'anime')
         graph.add_edge('user1', val3[0], val3[1])
     for val4 in vals_so_far2:
         graph.add_vertex(val4[0], 'anime')
         graph.add_edge('user2', val4[0], val4[1])
     graph.add_vertex('user3', 'user')
     predictor = NearestNeighbourPredictor(graph, 'pearson')
     vals_so_far3 = [(val5[0], val5[1],
                      predictor.predict_review_score('user2', val5[0]))
                     for val5 in vals_so_far1]
     vals_so_far4 = [(val5[0], val5[1],
                      predictor.predict_review_score('user1', val5[0]))
                     for val5 in vals_so_far2]
     vals_so_far5 = []
     for val6 in vals_so_far3:
         avg = (val6[1] + val6[2]) / 2
         graph.add_edge('user3', val6[0], avg)
         vals_so_far5.append((val6[0], avg))
     for val6 in vals_so_far4:
         avg = (val6[1] + val6[2]) / 2
         graph.add_edge('user3', val6[0], avg)
         vals_so_far5.append((val6[0], avg))
     recommendations = recommend_animes(vals_so_far5, 10, graph, 'pearson')
     self.window = QtWidgets.QWidget()
     self.ui = UiForm(recommendations)
     self.ui.setup_ui(self.window)
     self.widget.addWidget(self.window)
     self.widget.setCurrentIndex(self.widget.currentIndex() + 1)
コード例 #9
0
    def test_load_graph(self):
        input_str = """1
        300,300,255,0,0,0,255,0,0,0,255,0,0,0
        5
        0,300,300,0
        2
        0,300,300,0,100,100,100
        3
        0,300,300,300,255,255,0
        3
        0,0,0,300,255,0,255
        3
        0,0,300,0,0,0,100
        3
        300,0,300,300,0,100,0
        """

        graph = load_graph(StringIO(input_str))
        plot(graph)
コード例 #10
0
def main():
    start = None     # sets the parameters for bfs
    goal = None

    vertex_dict = load_graph("dartmouth_graph.txt")   # makes the dictionary for vertices
    image = load_image("dartmouth_map.png")           # loads the map for plotting
    
    enable_smoothing()
    
    while not window_closed():
        draw_image(image, 0, 0)
        for key in vertex_dict:                        # draws the points on the map and draws the edges between them in blue
            vertex_dict[key].draw_neighbor_edges(0, 0, 1)
            vertex_dict[key].draw(0, 0, 1)
            
        # makes the point that will later be the goal point, the point near the mouse
        found = None
        for key in vertex_dict:
            if vertex_dict[key].near_point(mouse_x(), mouse_y()):
                found = vertex_dict[key]
                break
        
        # makes the start vertex the clicked vertex    
        if mouse_down():
            start = found
        
        # makes the goal vertex the vertex that is closest to the mouse, and draws the start vertex in red.
        if start != None:
            start.draw(1, 0, 0)
            goal = found
        
        if start != None and goal != None:   # only runs this if there is a start and goal vertex.
            path = bfs(start, goal)
            previous = goal
            
            # draws the path in red and the vertices in the path in red
            for vertex in path:
                vertex.draw(1, 0, 0)
                vertex.draw_edge(previous, 1, 0, 0)
                previous = vertex
                
        request_redraw()
        sleep(.02)
コード例 #11
0
def draw_map():
    """
    Draws the map on the graphics window and plots the campus paths connecting various locations
    :return: None
    """
    img = load_image("dartmouth_map.png")  # Load the image
    vertex_dict = load_graph("dartmouth_graph.txt")

    enable_smoothing()
    draw_image(img, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, MAP_WIDTH/2, MAP_HEIGHT/2)

    for v in vertex_dict.values():
        enable_fill()
        v.draw_vertex(0, 0, 1)
        for u in v.adjacent_vertices:
            v.draw_edge(u, 0, 0, 1)

    set_mouse_button_function(draw_red_vertex)
    while not window_closed():
        dest_x = mouse_x()
        dest_y = mouse_y()

        request_redraw()
コード例 #12
0
ファイル: app.py プロジェクト: MerouaneBen/twitter-graph-viz
 def GET(self):
     return load_graph()
コード例 #13
0
ファイル: campusmap.py プロジェクト: rehoboth23/campusmap
# Author: Rehoboth Okorie
# Purpose: Plot a usable map of Dartmouth

from cs1lib import *
from load_graph import load_graph  # import the load_graph function; parses text file to create the vertex object
from bfs import bfs  # import the breadth first search function; finds the path between start and goal points

# get the vertices form the text document
dartmouth_graph_dict = load_graph("dart_textxtra.txt")

# load the campus map
dart_map = load_image("dartmouth_map.png")

# set start and goal on the path to be None at first
start, goal = None, None

# sets the mx and my to be zero before a start point is selected; goal is not dependent of mx & my
mx, my = 0, 0

# will contain the info to draw path from start to goal; get the info form the bfs call
path_dict = {}


# function to get mouse click position and saves it to mx, my
def press(mousex, mousey):
    global mx, my  # mx and my will only be updated when the mouse is clicked
    mx, my = mousex, mousey


# called by start graphics
def draw_graph():
コード例 #14
0
# lab4_checkpoint.py
# CS 1 Lab Assignment #4 checkpoint by THC.
# Creates a dictionary of Vertex objects based on reading in a file.
# Writes out a string for each Vertex object to a file.

from load_graph import load_graph
from bfs import breadth_first_search

vertex_dict = load_graph("dartmouth_graph.txt")

out_file = open("vertices.txt", "w")
for vertex in vertex_dict:
    out_file.write(str(vertex_dict[vertex]) + "\n")
out_file.close()
コード例 #15
0
ファイル: map_plot.py プロジェクト: kartikmenon/BFS-Graphs
# Program to draw vertices on a map
# Kartikeya Menon
# May 2013

from cs1lib import *
from load_graph import load_graph
from bfs import bfs

NAPTIME = 1. / 50

dictionary = load_graph("dartmouth_graph.txt")


def map_DM():

    # Loading the map
    map1 = load_image("dartmouth_map.png")
    draw_image(map1, 0, 0)

    # Initializing some variables. When nothing is clicked, the vertices will register as not found.
    start_found = False  # start_found and goal_found are Booleans that will check if a start or goal has been chosen.
    goal_found = False
    start = None  # These will store the actual vertex objects.
    goal = None

    #Main graphics loop.
    while not window_closed():

        # Looping through all of the vertices in the dictionary.
        for vertex in dictionary:
コード例 #16
0
from cs1lib import *
from load_graph import load_graph
from bfs import bfs

# window height and width
WINDOW_HEIGHT = 811
WINDOW_WIDTH = 1012

# state variables
start = None
goal = None
goal_found = False
start_found = False

# vertex dictionary
vertex_dict = load_graph("dartmouth_graph.txt")


# load map
def pic(img):
    draw_image(load_image(img), 0, 0)


def main():
    global start, goal, goal_found, start_found

    # load map
    pic("dartmouth_map.png")

    # draw each vertex & the connect-y line things in blue
    for location in vertex_dict:
コード例 #17
0
ファイル: main.py プロジェクト: Comp-UFSCar/graph-theory
    Grato pela compreensao
    """
    inicio = datetime.datetime.now()

    # Grafos onde havera simulacao
    uk12 = True
    wg59 = True
    usair97 = True

    if uk12 is True:
        # Simulacao do grafo UK12, com k = 2
        data['uk12']['a'] = {}
        data['uk12']['b'] = {}
        data['uk12']['lbl'] = []

        data['uk12']['grafo'] = load_graph(data['uk12']['dist'],data['uk12']['name'])

        # Lista com os nomes dos vertices
        for i in data['uk12']['grafo'].nodes(data=True):
            data['uk12']['lbl'].append(i[1]['name'])

        # Usaremos a periferia para obter duas sementes espalhadas
        data['uk12']['a']['seeds'] = nx.periphery(data['uk12']['grafo'])

        # Usaremos um vertice aleatorio e um de seus vizinhos como sementes proximas uma da outra
        random_v = np.random.randint(0, len(data['uk12']['grafo'].nodes()))

        data['uk12']['b']['seeds'] = ([random_v,
                     data['uk12']['grafo'].neighbors(random_v)
                     [np.random.randint(0, len(data['uk12']['grafo'].neighbors(random_v)))]])
コード例 #18
0
    calls compute_resilience and returns the list of largest connected components
    """
    #list_of_nodes = random_order(graph)
    list_of_nodes = fast_targeted_order(graph)
    connected_comps = compute_resilience(graph, list_of_nodes)
    plot = []
    #start_range = len(list_of_nodes)
    for no_of_nodes_removed in range(0, len(list_of_nodes)):
        plot.append([no_of_nodes_removed, connected_comps[no_of_nodes_removed]])
    return plot

##########################################
# plotting code

# plot computer network resillience
graph = load_graph(NETWORK_URL)
computer_network_plot = prepare_plot(graph)

# plot ER graph resilience
probability = 0.00175
graph = make_undirected_random_graph(NUM_NODES, probability)
er_plot = prepare_plot(graph)

# plot UPA graph resilience
initial_num = 2
graph = upa(NUM_NODES, initial_num)
upa_plot = prepare_plot(graph)

simpleplot.plot_lines("Plot of Network Resilience under attack\nfast_targeted_order(Desktop Python)", 700, 700, 
                        "nodes removed", "largest_connected_component", 
                        [computer_network_plot, er_plot, upa_plot], False, 
コード例 #19
0
import matplotlib.pyplot as plt
import networkx as nx
from load_graph import load_graph

graph = load_graph("data.json")

G = nx.Graph()


def getLabel(name):

    if graph.get_nodes()[name]['json_class'] == 'Actor':

        return name + " age: " + str(graph.get_nodes()[name]["age"])
    else:
        return name + " gross: " + str(graph.get_nodes()[name]["box_office"])


s = 'Mickey Rourke'

neimovies = graph.get_neighbors(s)

for nei in neimovies:

    G.add_edge(getLabel(s), getLabel(nei))

    for act in graph.get_neighbors(nei):

        G.add_edge(getLabel(act), getLabel(nei))

pos = nx.spring_layout(G)
コード例 #20
0
        path = search(vertex_dict[start_vertex_key],
                      vertex_dict[end_vertex_key])
        for item in path:
            item.set_vertex_color(RED)
            item.set_highlighted(True)


def draw_map():
    draw_image(map_image, 0, 0)
    check_mouse(mouse_x(), mouse_y())

    # I use two for loops to ensure that the vertexes all get drawn on top of the edges
    # Important because edges are double drawn
    for key in vertex_dict:
        vertex_dict[key].draw_lines(LINE_WIDTH)
    for key in vertex_dict:
        vertex_dict[key].draw_vertex(VERTEX_RADIUS)


map_image = load_image(MAP_FILE_NAME)
vertex_dict = load_graph(GRAPH_FILE_NAME)
start_vertex_key = None
end_vertex_key = None
clicked = False  # keeps track of whether the mouse has been pressed

start_graphics(draw_map,
               width=WINDOW_WIDTH,
               height=WINDOW_HEIGHT,
               mouse_press=pressed,
               mouse_release=released)
コード例 #21
0
from cs1lib import *
from vertex import Vertex
from load_graph import load_graph
from my_bfs import bfs
PIXEL_WIDTH = 1012
PIXEL_HEIGHT = 800

LINE_WIDTH = 5

image = load_image('dartmouth_map.png')
vertex_dictionary = load_graph('dartmouth_graph.txt')

start_vertex = None
goal_vertex = None
start_chosen = None
goal_chosen = None

#mouse click within a circle radius will trigger


def mouse_down(mx, my):
    global x, y, button_down, start_vertex, start_chosen
    #put 'in circle radius function' in here
    button_down = True
    x = mx
    y = my
    if button_down:
        if start_chosen == None:
            for place in vertex_dictionary:
                v = vertex_dictionary[place]
                if v.in_circle_radius(x, y):
コード例 #22
0
ファイル: map_plot.py プロジェクト: kartikmenon/BFS-Graphs
# Program to draw vertices on a map
# Kartikeya Menon
# May 2013

from cs1lib import *
from load_graph import load_graph
from bfs import bfs

NAPTIME = 1./50

dictionary = load_graph("dartmouth_graph.txt")


def map_DM():
    
    # Loading the map
    map1 = load_image("dartmouth_map.png")
    draw_image(map1, 0, 0)
    
    # Initializing some variables. When nothing is clicked, the vertices will register as not found.
    start_found = False # start_found and goal_found are Booleans that will check if a start or goal has been chosen.
    goal_found = False
    start = None # These will store the actual vertex objects.
    goal = None
    
    
    #Main graphics loop.
    while not window_closed():
        
        # Looping through all of the vertices in the dictionary.
        for vertex in dictionary:
コード例 #23
0
Liste as 3 melhores soluções e as 3 piores obtidas. Qual a diferença de custo entre a melhor e a pior? Discuta como a
diferença pode ser significativa.
"""

import networkx as nx
from prim import prim
import load_graph
import os
import matplotlib.pyplot as plt

dataset = [('ha30_dist.txt','ha30_name.txt'), ('sgb128_dist.txt','sgb128_name.txt'), ('wg59_dist.txt','wg59_name.txt')]


# Itera entre cada dataset
for data in dataset:
    G = load_graph.load_graph(os.path.abspath('..')+'\\ufscar-2014-graph-theory-task5a\\Datasets\\'+data[0],
                              os.path.abspath('..')+'\\ufscar-2014-graph-theory-task5a\\Datasets\\'+data[1])

    # Aplica o algoritmo de Prim para 10 árvores diferentes
    msts = []
    for i in range(10):
        T = prim(G)
        # Transforma o Grafo em um Digrafo e o coloca em um vetor de 10 posicoes
        mst_digraph = T.to_directed()
        msts.append((mst_digraph))

    # Aplica a busca de caminhos eulerianos

    # Verificacao que a arvore eh euleriana
    # if nx.is_eulerian(mst_digraph) == True:
    #    print "A arvore eh euleriana!"
コード例 #24
0
#当事关系   1      0 原告 1 被告 2 律师 3 代表人 4 代理人 5 审判长 6 审判员 7 法院
#诉讼关系   2      0 被诉 1 起诉
#辩护关系   3      0 被辩护 1 辩护
#代表关系   4      0 被代表 1 代表 2 被委托(代理) 3 委托(被代理)
#法院关系   5      0 审判长 1 审判员
#地点关系   6      0 住所地 1 出生地 2 户籍地
#时间关系   7      0 出生日期 1 判决日期
#属性关系   8      0 性别 1 民族 2 机构社会编号 3 律所 4 律师执业证号

edge_matrix = [[], ['当事人', '当事人', '律师', '代表人', '代理人', '审判长', '审判员', '法院'],
               ['被诉', '起诉'], ['被辩护', '辩护'],
               ['被代表', '代表', '委托(被代理)', '被委托(代理)'], ['审判长', '审判员'],
               ['住所地', '出生地', '户籍地'], ['出生日期', '判决日期'],
               ['性别', '民族', '机构社会编号', '律所', '律师执业证号']]

nodes_graph = load_graph.load_graph()


#mode 模式 by_step 查询与该节点n步距离内的所有节点,n由distance参数给出
# by_case 查询与该节点相关的案件,并且给出与该案件相关的所有节点
def query(id, mode='by_step', distance=1):
    if not nodes_graph.has_key(id):
        return []

    worked_nodes = []
    working_nodes = [id]
    tmp_nodes = []
    result = []
    for mul in range(distance + 1):
        result.append([])
    info = nodes_graph[id]
コード例 #25
0
import tensorflow as tf
from load_graph import load_graph

# We use our "load_graph" function
graph = load_graph("./model/tf_model.pb")

# We can verify that we can access the list of operations in the graph
for op in graph.get_operations():
    print(op.name)  # <--- printing the operations snapshot below
    # prefix/Placeholder/inputs_placeholder
    # ...
    # prefix/Accuracy/predictions

# We access the input and output nodes
x = graph.get_tensor_by_name('prefix/input_1:0')
# Tensor("ident_boxes/Identity:0", shape=(?, 300, 4), dtype=float32)
# Tensor("ident_scores/Identity:0", shape=(?, 300), dtype=float32)
# Tensor("ident_labels/Identity:0", shape=(?, 300), dtype=int32)
boxes_out = graph.get_tensor_by_name("prefix/ident_boxes/Identity:0")
scores_out = graph.get_tensor_by_name("prefix/ident_scores/Identity:0")
labels_out = graph.get_tensor_by_name("prefix/ident_labels/Identity:0")
# classification_out = graph.get_tensor_by_name("prefix/classification/concat:0")
# regression_out = graph.get_tensor_by_name("prefix/regression/concat:0")
# y = graph.get_tensor_by_name('prefix/prediction_restore:0')

# We launch a Session
# with tf.Session(graph=graph) as sess:

# test_features = [[0.377745556,0.009904444,0.063231111,0.009904444,0.003734444,0.002914444,0.008633333,0.000471111,0.009642222,0.05406,0.050163333,7e-05,0.006528889,0.000314444,0.00649,0.043956667,0.016816667,0.001644444,0.016906667,0.00204,0.027342222,0.13864]]
# compute the predicted output for test_x
# pred_y = sess.run( y, feed_dict={x: test_features} )
コード例 #26
0
    def setUp(self):

        self.graph = load_graph('data.json')
コード例 #27
0
 def GET(self):
     return load_graph()
コード例 #28
0
# COSC 1
# Lab 3 - drawing code

from cs1lib import *
from load_graph import load_graph
from bfs import bfs

# setting global variables and the default color to blue
WINDOW_WIDTH = 1012
WINDOW_HEIGHT = 811
r = 0
g = 0
b = 1

# call the capabilities of load_graph to get the dictionary.
list_all_vertices = load_graph("dartmouth_graph.txt")
img = load_image("dartmouth_map.png")

# initiate variables
start_vertex = None
goal_vertex = None
special_vertex = None

# main drawing function
def main():
    global start_vertex, goal_vertex, r, g, b, special_vertex


    draw_image(img, 0, 0)

    # draw all the vertices and edges in blue
コード例 #29
0
ファイル: run_simulation.py プロジェクト: kreldjarn/cs144_mp2
import sim
from load_graph import load_graph

from select_best_neighbors import select_best_neighbors
from select_degree import select_degree

graph_name = 'testgraph2.json'
graph = load_graph(graph_name)
num_seeds = 10

strategies = {}
strategies['player1'] = select_best_neighbors(graph, num_seeds)
strategies['player2'] = select_degree(graph, num_seeds)

results = sim.run(graph, strategies)

for player, winnings in sorted(results.items()):
    print(str(player) + " got " + str(winnings) + " nodes")
コード例 #30
0
ファイル: output_nodes.py プロジェクト: kreldjarn/cs144_mp2
import json

from load_graph import load_graph
from select_best_neighbors import select_best_neighbors
from select_degree import select_degree

# select the graph and the allowed number of seeds
graph = load_graph('testgraph1.json')
num_seeds = 10

# save nodes as text file

# print nodes 50 times for different selection strategies

filename = 'nodes_best_neighbors.txt'
with open(filename, 'w') as nodes_file:

    # get seed nodes list for 50 games
    for k in range(0, 50):
        nodes = select_best_neighbors(graph, num_seeds)

        # write nodes to file
        for node in nodes:
            nodes_file.write(node + '\n')

filename = 'nodes_degree.txt'
with open(filename, 'w') as nodes_file:

    # get seed nodes list for 50 games
    for k in range(0, 50):
        nodes = select_degree(graph, num_seeds)
コード例 #31
0
from cs1lib import *
from load_graph import load_graph
from bfs import bfs
from math import *

vertices = load_graph("dartmouth_graph.txt")

WINDOW_WIDTH = 1012
WINDOW_HEIGHT = 811

def main():
    img = load_image("dartmouth_map")
    draw_image(img, 0, 0)
    
    start = None
    goal = None
    
    #initialize map with blue vertices
    for key in vertices:
        vertices[key].draw_vertex(0,0,1)
        for adjacent_vertex in vertices[key].list:
            vertices[key].draw_edge(adjacent_vertex, 0, 0, 1)
    
    while not window_closed(): 
        
        for key in vertices:
            if vertices[key].is_touched() and mouse_down():
                #reset map every time new starting vertex selected
                for generic_vertex in vertices:
                    vertices[generic_vertex].draw_vertex(0,0,1)
                    for adjacent_vertex in vertices[generic_vertex].list:
コード例 #32
0
ファイル: evaluate.py プロジェクト: TrySickle/metrics
import argparse 
import tensorflow as tf
from load_graph import load_graph
import dataset_loading
import numpy as np
import functions

if __name__ == '__main__':
    # Let's allow the user to pass the filename as an argument
    parser = argparse.ArgumentParser()
    parser.add_argument("--frozen_model_filename", default="model/affordance-cvae-27000-2-final.ckpt.bytes", type=str, help="Frozen model file to import")
    args = parser.parse_args()

    # We use our "load_graph" function
    graph = load_graph(args.frozen_model_filename)

    # load data
    vr_data = dataset_loading.read_timeseries_data_only_train('VR_data')

    # We can verify that we can access the list of operations in the graph
    # for op in graph.get_operations():
    #     print(op.name)
        # prefix/Placeholder/inputs_placeholder
        # ...
        # prefix/Accuracy/predictions
        
    # We access the input and output nodes 
    input_dims = 27000
    cond_dims = 25
    X_in = graph.get_tensor_by_name('prefix/X:0')
    Cond = graph.get_tensor_by_name('prefix/Cond:0')
コード例 #33
0
    plt.title("Gross for different age group")

    maxi = 0

    for i in range(len(grossCounts)):

        if grossCounts[i] > grossCounts[maxi]:
            maxi = i

    print("Age group %s generates the most amount of money" % groups[maxi])

    plt.show()


if __name__ == '__main__':

    from load_graph import load_graph

    graph = load_graph('data.json')

    top3 = get_top_k_hub_actors(graph, 3)

    top3 = [(x['name'], n) for x, n in top3]

    print("Top 3 hub actors")

    print(top3)

    plot_age_group_gross(graph)
コード例 #34
0
ファイル: predict.py プロジェクト: sahilb/tfjs
import load_graph
import tensorflow as tf
import numpy as np

graph = load_graph.load_graph('ck_model/frozen_model.pb')

for op in graph.get_operations():
    print(op.name)

y = graph.get_tensor_by_name('prefix/actor/actor_out/Softmax:0')
x = graph.get_tensor_by_name('prefix/actor/InputData/X:0')

print(x)
print(y)

a = np.arange(0, 48).reshape(1, 6, 8)
with tf.Session(graph=graph) as sess:
    y_out = sess.run(y, feed_dict={x: a})

print(y_out)