@@ -6,15 +6,13 @@ import (
6
6
"bufio"
7
7
"context"
8
8
"fmt"
9
- "math"
10
9
"os"
11
10
"path/filepath"
12
11
"strings"
13
12
"sync"
14
13
15
14
"github.com/pkg/errors"
16
15
"go.opencensus.io/trace"
17
- "golang.org/x/exp/constraints"
18
16
19
17
"go.viam.com/rdk/logging"
20
18
"go.viam.com/rdk/ml"
@@ -299,88 +297,6 @@ func getIndex(s []int, num int) int {
299
297
return - 1
300
298
}
301
299
302
- // softmax takes the input slice and applies the softmax function.
303
- func softmax (in []float64 ) []float64 {
304
- out := make ([]float64 , 0 , len (in ))
305
- bigSum := 0.0
306
- for _ , x := range in {
307
- bigSum += math .Exp (x )
308
- }
309
- for _ , x := range in {
310
- out = append (out , math .Exp (x )/ bigSum )
311
- }
312
- return out
313
- }
314
-
315
- // Number interface for converting between numbers.
316
- type number interface {
317
- constraints.Integer | constraints.Float
318
- }
319
-
320
- // convertNumberSlice converts any number slice into another number slice.
321
- func convertNumberSlice [T1 , T2 number ](t1 []T1 ) []T2 {
322
- t2 := make ([]T2 , len (t1 ))
323
- for i := range t1 {
324
- t2 [i ] = T2 (t1 [i ])
325
- }
326
- return t2
327
- }
328
-
329
- func convertToFloat64Slice (slice interface {}) ([]float64 , error ) {
330
- switch v := slice .(type ) {
331
- case []float64 :
332
- return v , nil
333
- case float64 :
334
- return []float64 {v }, nil
335
- case []float32 :
336
- return convertNumberSlice [float32 , float64 ](v ), nil
337
- case float32 :
338
- return convertNumberSlice [float32 , float64 ]([]float32 {v }), nil
339
- case []int :
340
- return convertNumberSlice [int , float64 ](v ), nil
341
- case int :
342
- return convertNumberSlice [int , float64 ]([]int {v }), nil
343
- case []uint :
344
- return convertNumberSlice [uint , float64 ](v ), nil
345
- case uint :
346
- return convertNumberSlice [uint , float64 ]([]uint {v }), nil
347
- case []int8 :
348
- return convertNumberSlice [int8 , float64 ](v ), nil
349
- case int8 :
350
- return convertNumberSlice [int8 , float64 ]([]int8 {v }), nil
351
- case []int16 :
352
- return convertNumberSlice [int16 , float64 ](v ), nil
353
- case int16 :
354
- return convertNumberSlice [int16 , float64 ]([]int16 {v }), nil
355
- case []int32 :
356
- return convertNumberSlice [int32 , float64 ](v ), nil
357
- case int32 :
358
- return convertNumberSlice [int32 , float64 ]([]int32 {v }), nil
359
- case []int64 :
360
- return convertNumberSlice [int64 , float64 ](v ), nil
361
- case int64 :
362
- return convertNumberSlice [int64 , float64 ]([]int64 {v }), nil
363
- case []uint8 :
364
- return convertNumberSlice [uint8 , float64 ](v ), nil
365
- case uint8 :
366
- return convertNumberSlice [uint8 , float64 ]([]uint8 {v }), nil
367
- case []uint16 :
368
- return convertNumberSlice [uint16 , float64 ](v ), nil
369
- case uint16 :
370
- return convertNumberSlice [uint16 , float64 ]([]uint16 {v }), nil
371
- case []uint32 :
372
- return convertNumberSlice [uint32 , float64 ](v ), nil
373
- case uint32 :
374
- return convertNumberSlice [uint32 , float64 ]([]uint32 {v }), nil
375
- case []uint64 :
376
- return convertNumberSlice [uint64 , float64 ](v ), nil
377
- case uint64 :
378
- return convertNumberSlice [uint64 , float64 ]([]uint64 {v }), nil
379
- default :
380
- return nil , errors .Errorf ("dont know how to convert slice of %T into a []float64" , slice )
381
- }
382
- }
383
-
384
300
// tensorNames returns all the names of the tensors.
385
301
func tensorNames (t ml.Tensors ) []string {
386
302
names := []string {}
0 commit comments