MCPcopy Index your code
hub / github.com/waleedka/hiddenlayer / apply

Method apply

hiddenlayer/transforms.py:28–49  ·  view source on GitHub ↗
(self, graph)

Source from the content-addressed store, hash-verified

26 self.name = name
27
28 def apply(self, graph):
29 # Copy the graph. Don't change the original.
30 graph = copy.deepcopy(graph)
31
32 while True:
33 matches, _ = graph.search(self.pattern)
34 if not matches:
35 break
36
37 # Replace pattern with new node
38 if self.op == "__first__":
39 combo = matches[0]
40 elif self.op == "__last__":
41 combo = matches[-1]
42 else:
43 combo = Node(uid=graph.sequence_id(matches),
44 name=self.name or " > ".join([l.title for l in matches]),
45 op=self.op or self.pattern,
46 output_shape=matches[-1].output_shape)
47 combo._caption = "/".join(filter(None, [l.caption for l in matches]))
48 graph.replace(matches, combo)
49 return graph
50
51
52class FoldId():

Callers 4

test_foldMethod · 0.95
test_parallel_foldMethod · 0.95
build_graphFunction · 0.45
__init__Method · 0.45

Calls 4

NodeClass · 0.85
searchMethod · 0.80
sequence_idMethod · 0.80
replaceMethod · 0.80

Tested by 2

test_foldMethod · 0.76
test_parallel_foldMethod · 0.76