File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1010
1111load_dotenv ()
1212
13+ def calculate_average_loss (graph : NetworkXStorage ):
14+ """
15+ Calculate the average loss of the graph.
16+
17+ :param graph: NetworkXStorage
18+ :return: float
19+ """
20+ edges = asyncio .run (graph .get_all_edges ())
21+ total_loss = 0
22+ for edge in edges :
23+ total_loss += edge [2 ]['loss' ]
24+ return total_loss / len (edges )
25+
26+
1327
1428if __name__ == '__main__' :
1529 parser = argparse .ArgumentParser ()
3852 graph_file = asyncio .run (graph_storage .get_graph ())
3953
4054 new_graph .write_nx_graph (graph_file , args .output )
55+
56+ average_loss = calculate_average_loss (graph_storage )
57+ print (f"Average loss of the graph: { average_loss } " )
Original file line number Diff line number Diff line change 1- python3 evaluate .py --output cache/output/new_graph.graphml \
1+ python3 judge .py --output cache/output/new_graph.graphml \
You can’t perform that action at this time.
0 commit comments