This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
A quick, partial implementation of ENet (https://arxiv.org/abs/1606.02147) using PyTorch. | |
The original Torch ENet implementation can process a 480x360 image in ~12 ms (on a P2 AWS | |
instance). TensorFlow takes ~35 ms. The PyTorch implementation takes ~25 ms, an improvement | |
over TensorFlow, but worse than the original Torch. | |
""" | |
from __future__ import absolute_import |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def total_length_graph(graph): | |
v_ew, _ =vertex_degree1_edge_weight(T) | |
return np.sum(v_ew.values()) | |
def response_to_iterative_pruning(graph): | |
'''return the number of vertices of degree 1 as a function of the number of pruning | |
''' | |
response = [] | |
response.append((0,number_of_degree1_vertices(graph))) | |
#print number_of_degree1_vertices(graph) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def at_least_one_vertex_of_degree_above_one(graph): | |
''' check if there's at least one vertex of degree above 1 in the graph. | |
''' | |
graph = gt.GraphView(graph, vfilt= lambda v : v.out_degree() > 1) | |
try: | |
first = next(graph.vertices()) | |
except StopIteration: | |
return False | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_toy_graph(): | |
T = gt.Graph(directed = False) | |
edge_weights = T.new_edge_property('double') | |
T.properties[("e","weight")] = edge_weights | |
T.add_vertex(n=4) | |
e_1 = T.add_edge(0,1) | |
e_2 = T.add_edge(1,2) | |
e_3 = T.add_edge(0,0) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.