MCPcopy
hub / github.com/dgraph-io/dgraph / GenerateRandomVector

Function GenerateRandomVector

dgraphapi/vector.go:17–23  ·  view source on GitHub ↗
(size int)

Source from the content-addressed store, hash-verified

15)
16
17func GenerateRandomVector(size int) []float32 {
18 vector := make([]float32, size)
19 for i := range size {
20 vector[i] = rand.Float32() * 10
21 }
22 return vector
23}
24
25func formatVector(label string, vector []float32, index int) string {
26 vectorString := fmt.Sprintf(`"[%s]"`, strings.Trim(strings.Join(strings.Fields(fmt.Sprint(vector)), ", "), "[]"))

Callers 3

GenerateRandomVectorsFunction · 0.85

Calls

no outgoing calls

Tested by 2