util

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileSystem = afs.New()

Functions

func ArgMax

func ArgMax(s []float32) (int, float32, error)

ArgMax find both index of max value in s and max value.

func CloseFile

func CloseFile(file io.Closer) error

func GetPathType

func GetPathType(path string) string

func Mean

func Mean(vector []float32) float32

Mean of a float32 vector.

func Norm

func Norm(v []float32, p int) float64

Norm of a vector.

func Normalize

func Normalize(embedding []float32, p int) []float32

Normalize single vector according to: https://pytorch.org/docs/stable/generated/torch.nn.functional.normalize.html

func OpenFile added in v0.3.0

func OpenFile(filename string) (io.ReadCloser, error)

func PathJoinSafe

func PathJoinSafe(elem ...string) string

PathJoinSafe wrapper around filepath.Join to ensure that paths are correctly constructed if the path is a normal OS path, just use filepath.Join if the path is S3, trim any trailing slashes and construct it manually from the components so that double slashes (e.g. s3://) are preserved.

func ReadFileBytes

func ReadFileBytes(filename string) ([]byte, error)

func ReadLine added in v0.3.0

func ReadLine(r *bufio.Reader) ([]byte, error)

ReadLine returns a single line (without the ending \n) from the input buffered reader. An error is returned if there is an error with the buffered reader. This function is needed to avoid the 65K char line limit

func Sigmoid

func Sigmoid(s []float32) []float32

func SoftMax

func SoftMax(vector []float32) []float32

SoftMax take a vector and calculate softmax scores of its values.

func SumSlice

func SumSlice(s []float64) float64

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL