Documentation ¶
Index ¶
- Constants
- func CheckPanic()
- func Escape(text string) string
- func GetRandomName(retry int) string
- func MarshalIndex(w io.Writer, index Index) error
- func NewMatrix32(row, col int) [][]float32
- func NewMatrixInt(row, col int) [][]int
- func RangeInt(n int) []int
- func ReadLines(sc *bufio.Scanner, sep string, handler func(int, []string) bool) error
- func RepeatFloat32s(n int, value float32) []float32
- func ValidateId(text string) error
- func ValidateLabel(text string) error
- type Array
- type DirectIndex
- func (idx *DirectIndex) Add(s string)
- func (idx *DirectIndex) Bytes() int
- func (idx *DirectIndex) GetNames() []string
- func (idx *DirectIndex) Len() int32
- func (idx *DirectIndex) Marshal(w io.Writer) error
- func (idx *DirectIndex) ToName(index int32) string
- func (idx *DirectIndex) ToNumber(name string) int32
- func (idx *DirectIndex) Unmarshal(r io.Reader) error
- type Index
- type MapIndex
- func (idx *MapIndex) Add(name string)
- func (idx *MapIndex) Bytes() int
- func (idx *MapIndex) GetNames() []string
- func (idx *MapIndex) Len() int32
- func (idx *MapIndex) Marshal(w io.Writer) error
- func (idx *MapIndex) ToName(index int32) string
- func (idx *MapIndex) ToNumber(name string) int32
- func (idx *MapIndex) Unmarshal(r io.Reader) error
- type RandomGenerator
- func (rng RandomGenerator) NewNormalVector(size int, mean, stdDev float32) []float32
- func (rng RandomGenerator) NormalMatrix(row, col int, mean, stdDev float32) [][]float32
- func (rng RandomGenerator) NormalVector64(size int, mean, stdDev float64) []float64
- func (rng RandomGenerator) Sample(low, high, n int, exclude ...*iset.Set) []int
- func (rng RandomGenerator) SampleInt32(low, high int32, n int, exclude ...*i32set.Set) []int32
- func (rng RandomGenerator) UniformMatrix(row, col int, low, high float32) [][]float32
- func (rng RandomGenerator) UniformVector(size int, low, high float32) []float32
Constants ¶
const NotId = int32(-1)
NotId represents an ID doesn't exist.
Variables ¶
This section is empty.
Functions ¶
func GetRandomName ¶ added in v0.2.0
GetRandomName generates a random name from the list of adjectives and surnames in this package formatted as "adjective_surname". For example 'focused_turing'. If retry is non-zero, a random integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`
func MarshalIndex ¶ added in v0.2.7
MarshalIndex marshal index into byte stream.
func NewMatrix32 ¶ added in v0.2.0
NewMatrix32 creates a 2D matrix of 32-bit floats.
func NewMatrixInt ¶
NewMatrixInt creates a 2D matrix of integers.
func RepeatFloat32s ¶ added in v0.2.5
RepeatFloat32s repeats value n times.
func ValidateId ¶ added in v0.2.0
ValidateId validates user/item id. Id cannot be empty and contain [/,].
func ValidateLabel ¶ added in v0.2.0
ValidateLabel validates label. Label cannot be empty and contain [/,|].
Types ¶
type DirectIndex ¶ added in v0.2.0
type DirectIndex struct {
Limit int32
}
DirectIndex means that the name and its index is the same. For example, the index of "1" is 1, vice versa.
func NewDirectIndex ¶ added in v0.2.0
func NewDirectIndex() *DirectIndex
NewDirectIndex create a direct mapping index.
func (*DirectIndex) Add ¶ added in v0.2.0
func (idx *DirectIndex) Add(s string)
Add a name to current index.
func (*DirectIndex) Bytes ¶ added in v0.4.3
func (idx *DirectIndex) Bytes() int
func (*DirectIndex) GetNames ¶ added in v0.2.0
func (idx *DirectIndex) GetNames() []string
GetNames returns all names in current index.
func (*DirectIndex) Len ¶ added in v0.2.0
func (idx *DirectIndex) Len() int32
Len returns the number of names in current index.
func (*DirectIndex) Marshal ¶ added in v0.2.7
func (idx *DirectIndex) Marshal(w io.Writer) error
Marshal direct index into byte stream.
func (*DirectIndex) ToName ¶ added in v0.2.0
func (idx *DirectIndex) ToName(index int32) string
ToName converts a index to corresponding name.
func (*DirectIndex) ToNumber ¶ added in v0.2.0
func (idx *DirectIndex) ToNumber(name string) int32
ToNumber converts a name to corresponding index.
type Index ¶ added in v0.2.0
type Index interface { Len() int32 Add(name string) ToNumber(name string) int32 ToName(index int32) string GetNames() []string Marshal(w io.Writer) error Unmarshal(r io.Reader) error Bytes() int }
Index keeps the mapping between names (string) and indices (integer).
type MapIndex ¶ added in v0.2.0
type MapIndex struct { Numbers map[string]int32 // sparse ID -> dense index Names []string // dense index -> sparse ID Characters int }
MapIndex manages the map between sparse Names and dense indices. A sparse ID is a user ID or item ID. The dense index is the internal user index or item index optimized for faster parameter access and less memory usage.
type RandomGenerator ¶
RandomGenerator is the random generator for gorse.
func NewRandomGenerator ¶
func NewRandomGenerator(seed int64) RandomGenerator
NewRandomGenerator creates a RandomGenerator.
func (RandomGenerator) NewNormalVector ¶
func (rng RandomGenerator) NewNormalVector(size int, mean, stdDev float32) []float32
NewNormalVector makes a vec filled with normal random floats.
func (RandomGenerator) NormalMatrix ¶ added in v0.2.0
func (rng RandomGenerator) NormalMatrix(row, col int, mean, stdDev float32) [][]float32
NormalMatrix makes a matrix filled with normal random floats.
func (RandomGenerator) NormalVector64 ¶ added in v0.2.0
func (rng RandomGenerator) NormalVector64(size int, mean, stdDev float64) []float64
NormalVector64 makes a vec filled with normal random floats.
func (RandomGenerator) Sample ¶ added in v0.2.0
func (rng RandomGenerator) Sample(low, high, n int, exclude ...*iset.Set) []int
Sample n values between low and high, but not in exclude.
func (RandomGenerator) SampleInt32 ¶ added in v0.2.6
SampleInt32 n 32bit values between low and high, but not in exclude.
func (RandomGenerator) UniformMatrix ¶ added in v0.2.0
func (rng RandomGenerator) UniformMatrix(row, col int, low, high float32) [][]float32
UniformMatrix makes a matrix filled with uniform random floats.
func (RandomGenerator) UniformVector ¶ added in v0.2.0
func (rng RandomGenerator) UniformVector(size int, low, high float32) []float32
UniformVector makes a vec filled with uniform random floats,