Documentation ¶
Overview ¶
Copyright 2020 gorse Project Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 gorse Project Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 gorse Project Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 gorse Project Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 gorse Project Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func BatchParallel(nJobs int, nWorkers int, batchSize int, ...) error
- func CheckPanic()
- func GCD(a ...int) int
- func GetRandomName(retry int) string
- func Hex(v int64) string
- func Logger() *zap.Logger
- func Max(a ...int) int
- func Min(a ...int) int
- func NewMatrix32(row, col int) [][]float32
- func NewMatrixInt(row, col int) [][]int
- func Now() string
- func Parallel(nJobs int, nWorkers int, worker func(workerId, jobId int) error) error
- func RangeInt(n int) []int
- func SetLogger(_logger *zap.Logger)
- type DirectIndex
- type Index
- type MapIndex
- 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) NormalMatrix64(row, col int, mean, stdDev float64) [][]float64
- 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) UniformMatrix(row, col int, low, high float32) [][]float32
- func (rng RandomGenerator) UniformVector(size int, low, high float32) []float32
- type TopKFilter
- type TopKStringFilter
Constants ¶
const NotId = -1
NotId represents an ID doesn't exist.
Variables ¶
This section is empty.
Functions ¶
func BatchParallel ¶ added in v0.2.0
func CheckPanic ¶ added in v0.2.0
func CheckPanic()
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 NewMatrix32 ¶ added in v0.2.0
func NewMatrixInt ¶
Types ¶
type DirectIndex ¶ added in v0.2.0
type DirectIndex struct {
Limit int
}
func NewDirectIndex ¶ added in v0.2.0
func NewDirectIndex() *DirectIndex
func (*DirectIndex) Add ¶ added in v0.2.0
func (idx *DirectIndex) Add(s string)
func (*DirectIndex) GetNames ¶ added in v0.2.0
func (idx *DirectIndex) GetNames() []string
func (*DirectIndex) Len ¶ added in v0.2.0
func (idx *DirectIndex) Len() int
func (*DirectIndex) ToName ¶ added in v0.2.0
func (idx *DirectIndex) ToName(index int) string
func (*DirectIndex) ToNumber ¶ added in v0.2.0
func (idx *DirectIndex) ToNumber(name string) int
type MapIndex ¶ added in v0.2.0
type MapIndex struct { Numbers map[string]int // sparse ID -> dense index Names []string // dense index -> sparse ID }
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) NormalMatrix64 ¶ added in v0.2.0
func (rng RandomGenerator) NormalMatrix64(row, col int, mean, stdDev float64) [][]float64
NormalMatrix64 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
NewNormalVector 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
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,
type TopKFilter ¶ added in v0.2.0
type TopKFilter struct {
// contains filtered or unexported fields
}
func NewTopKFilter ¶ added in v0.2.0
func NewTopKFilter(k int) *TopKFilter
func (*TopKFilter) Len ¶ added in v0.2.0
func (filter *TopKFilter) Len() int
func (*TopKFilter) Less ¶ added in v0.2.0
func (filter *TopKFilter) Less(i, j int) bool
func (*TopKFilter) PopAll ¶ added in v0.2.0
func (filter *TopKFilter) PopAll() ([]int, []float32)
func (*TopKFilter) Push ¶ added in v0.2.0
func (filter *TopKFilter) Push(item int, weight float32)
Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Count().
func (*TopKFilter) Swap ¶ added in v0.2.0
func (filter *TopKFilter) Swap(i, j int)
type TopKStringFilter ¶ added in v0.2.0
type TopKStringFilter struct {
// contains filtered or unexported fields
}
func NewTopKStringFilter ¶ added in v0.2.0
func NewTopKStringFilter(k int) *TopKStringFilter
func (*TopKStringFilter) Len ¶ added in v0.2.0
func (filter *TopKStringFilter) Len() int
func (*TopKStringFilter) Less ¶ added in v0.2.0
func (filter *TopKStringFilter) Less(i, j int) bool
func (*TopKStringFilter) PopAll ¶ added in v0.2.0
func (filter *TopKStringFilter) PopAll() ([]string, []float32)
func (*TopKStringFilter) Push ¶ added in v0.2.0
func (filter *TopKStringFilter) Push(item string, weight float32)
Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Count().
func (*TopKStringFilter) Swap ¶ added in v0.2.0
func (filter *TopKStringFilter) Swap(i, j int)