def __init__(self, node_num, p, in_channels, out_channels, graph_mode, is_train, name): super(RandWire, self).__init__() self.node_num = node_num self.p = p self.in_channels = in_channels self.out_channels = out_channels self.graph_mode = graph_mode self.is_train = is_train self.name = name # get graph nodes and in edges graph_node = RandomGraph(self.node_num, self.p, graph_mode=graph_mode) if self.is_train is True: print("is_train: True") graph = graph_node.make_graph() self.nodes, self.in_edges = graph_node.get_graph_info(graph) graph_node.save_random_graph(graph, name) else: graph = graph_node.load_random_graph(name) self.nodes, self.in_edges = graph_node.get_graph_info(graph) # define input Node self.module_list = nn.ModuleList([ Node(self.in_edges[0], self.in_channels, self.out_channels, stride=2) ]) # define the rest Node self.module_list.extend([ Node(self.in_edges[node], self.out_channels, self.out_channels) for node in self.nodes if node > 0 ])