MCPcopy Create free account
hub / github.com/amov-lab/Prometheus / sample

Function sample

Modules/object_detection/src/darknet_lib/python/darknet.py:5–13  ·  view source on GitHub ↗
(probs)

Source from the content-addressed store, hash-verified

3import random
4
5def sample(probs):
6 s = sum(probs)
7 probs = [a/s for a in probs]
8 r = random.uniform(0, 1)
9 for i in range(len(probs)):
10 r = r - probs[i]
11 if r <= 0:
12 return i
13 return len(probs)-1
14
15def c_array(ctype, values):
16 arr = (ctype*len(values))()

Callers 1

predict_tacticFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected