word2vec

package
v0.0.0-...-8f53c5d Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cbow

type Cbow struct {
	// contains filtered or unexported fields
}

Cbow behaviors as one of Word2vec solver.

func NewCbow

func NewCbow(dimension, window, threadSize int) *Cbow

NewCbow creates *Cbow

type HierarchicalSoftmax

type HierarchicalSoftmax struct {
	*SigmoidTable
	// contains filtered or unexported fields
}

HierarchicalSoftmax is a piece of Word2Vec optimizer.

func NewHierarchicalSoftmax

func NewHierarchicalSoftmax(maxDepth int) *HierarchicalSoftmax

NewHierarchicalSoftmax creates *HierarchicalSoftmax.

type Model

type Model interface {
	// contains filtered or unexported methods
}

Model is the interface to train a word vector.

type ModelType

type ModelType int
const (
	CBOW ModelType = iota
	SKIP_GRAM
)

func (ModelType) String

func (t ModelType) String() string

type NegativeSampling

type NegativeSampling struct {
	*SigmoidTable
	ContextVector []float64
	// contains filtered or unexported fields
}

NegativeSampling is a piece of Word2Vec optimizer.

func NewNegativeSampling

func NewNegativeSampling(sampleSize int) *NegativeSampling

NewNegativeSampling creates *NegativeSampling.

type Optimizer

type Optimizer interface {
	// contains filtered or unexported methods
}

Optimizer is the interface to initialize after scanning corpus once, and update the word vector.

type OptimizerType

type OptimizerType int
const (
	NEGATIVE_SAMPLING OptimizerType = iota
	HIERARCHICAL_SOFTMAX
)

func (OptimizerType) String

func (t OptimizerType) String() string

type SigmoidTable

type SigmoidTable struct {
	// contains filtered or unexported fields
}

SigmoidTable stores the values of sigmoid function.

type SkipGram

type SkipGram struct {
	// contains filtered or unexported fields
}

SkipGram behaviors as one of Word2vec solver.

func NewSkipGram

func NewSkipGram(dimension, window, threadSize int) *SkipGram

NewSkipGram creates *SkipGram

type Word2vec

type Word2vec struct {
	*model.Option
	*Word2vecOption
	*corpus.Word2vecCorpus
	// contains filtered or unexported fields
}

Word2vec stores the configs for Word2vec models.

func NewWord2vec

func NewWord2vec(option *model.Option, word2vecOption *Word2vecOption) *Word2vec

NewWord2vec creates *Word2Vec.

func (*Word2vec) Save

func (w *Word2vec) Save(outputPath string) error

Save saves the word vector to outputFile.

func (*Word2vec) Train

func (w *Word2vec) Train(f io.Reader) error

Train trains words' vector on corpus.

type Word2vecOption

type Word2vecOption struct {
	Mod                Model
	Opt                Optimizer
	SubsampleThreshold float64
	Theta              float64
}

Jump to

Keyboard shortcuts

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