MCPcopy Index your code
hub / github.com/geekcomputers/Python / evaluate

Method evaluate

ML/src/python/neuralforge/nas/evaluator.py:127–142  ·  view source on GitHub ↗
(self, architecture: Architecture, search_space: SearchSpace)

Source from the content-addressed store, hash-verified

125 self.device = device
126
127 def evaluate(self, architecture: Architecture, search_space: SearchSpace) -> Tuple[float, float]:
128 model = search_space.build_model(architecture)
129 model = model.to(self.device)
130
131 complexity = search_space.estimate_complexity(architecture)
132 params = complexity['params']
133 flops = complexity['flops']
134
135 num_layers = len([g for g in architecture.genome if g.get('type') != 'pooling'])
136
137 estimated_accuracy = 60.0 + torch.rand(1).item() * 20.0
138 estimated_accuracy = min(95.0, estimated_accuracy - params / 1e8)
139
140 fitness = estimated_accuracy - 0.1 * (params / 1e7) - 0.05 * (flops / 1e9)
141
142 return fitness, estimated_accuracy

Callers

nothing calls this directly

Calls 3

build_modelMethod · 0.80
estimate_complexityMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected