din

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func EucDistance

func EucDistance(x, y *G.Node) (retVal *G.Node)

EucDistance is the Euclidean distance between two matrix, typically used for calculating the distance between two embedding. Case1: x, y shapes are same, no broadcast. output shape will be x.shape[:-1] Case2: x, y shapes are different, broadcast will be applied on the smaller dim. output shape will be something like x.shape[:-1] but with a broadcast dim

func FillTensorRows added in v0.3.0

func FillTensorRows(batchSize int, inputs tensor.Tensor) (x tensor.Tensor, err error)

FillTensorRows fills the batch samples with the zero data to make sample size fit the batch size it sames tensor.Concat is not optimized for large dataset. we should avoid using FillTensorRows while input data is large.

func InitForwardOnlyVm

func InitForwardOnlyVm(uProfileDim, uBehaviorSize, uBehaviorDim, iFeatureDim, cFeatureDim int,
	batchSize int,
	m Model,
) (err error)

func PRelu

func PRelu(x, slop *G.Node) (retVal *G.Node)

PRelu is the slop learnable LeakyRelu activation function slop should be a scalar

func Predict

func Predict(m Model, numExamples, batchSize int, si *rcmd.SampleInfo, inputs tensor.Tensor) (y []float32, err error)

func Train

func Train(uProfileDim, uBehaviorSize, uBehaviorDim, iFeatureDim, cFeatureDim int,
	numExamples, batchSize, epochs, earlyStop int,
	si *rcmd.SampleInfo,
	inputs, targets tensor.Tensor,

	m Model,
) (err error)

Types

type DinNet

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

func NewDinNet

func NewDinNet(
	uProfileDim, uBehaviorSize, uBehaviorDim int,
	iFeatureDim int,
	cFeatureDim int,
) *DinNet

func NewDinNetFromJson

func NewDinNetFromJson(data []byte) (din *DinNet, err error)

func (*DinNet) Fwd

func (din *DinNet) Fwd(xUserProfile, xUbMatrix, xItemFeature, xCtxFeature *G.Node, batchSize, uBehaviorSize, uBehaviorDim int) (err error)

Fwd performs the forward pass xUserProfile: [batchSize, userProfileDim] xUbMatrix: [batchSize, uBehaviorSize* uBehaviorDim] xUserBehaviors: [batchSize, uBehaviorSize, uBehaviorDim] xItemFeature: [batchSize, iFeatureDim] xContextFeature: [batchSize, cFeatureDim]

func (*DinNet) Graph

func (din *DinNet) Graph() *G.ExprGraph

func (*DinNet) In

func (din *DinNet) In() G.Nodes

func (*DinNet) Marshal

func (din *DinNet) Marshal() (data []byte, err error)

func (*DinNet) Out

func (din *DinNet) Out() *G.Node

func (*DinNet) SetVM

func (din *DinNet) SetVM(vm G.VM)

func (*DinNet) Vm

func (din *DinNet) Vm() G.VM

type Model

type Model interface {
	Fwd(xUserProfile, ubMatrix, xItemFeature, xCtxFeature *G.Node, batchSize, uBehaviorSize, uBehaviorDim int) (err error)
	Out() *G.Node
	In() G.Nodes
	Graph() *G.ExprGraph
	Marshal() (data []byte, err error)
	Vm() G.VM
	SetVM(vm G.VM)
	// contains filtered or unexported methods
}

type SimpleMLP

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

func NewSimpleMLP

func NewSimpleMLP(
	uProfileDim, uBehaviorSize, uBehaviorDim int,
	iFeatureDim int,
	cFeatureDim int,
) (mlp *SimpleMLP)

func NewSimpleMLPFromJson

func NewSimpleMLPFromJson(data []byte) (mlp *SimpleMLP, err error)

func (*SimpleMLP) Fwd

func (mlp *SimpleMLP) Fwd(xUserProfile, ubMatrix, xItemFeature, xCtxFeature *G.Node, batchSize, uBehaviorSize, uBehaviorDim int) (err error)

func (*SimpleMLP) Graph

func (mlp *SimpleMLP) Graph() *G.ExprGraph

func (*SimpleMLP) In

func (mlp *SimpleMLP) In() G.Nodes

func (*SimpleMLP) Marshal

func (mlp *SimpleMLP) Marshal() (data []byte, err error)

func (*SimpleMLP) Out

func (mlp *SimpleMLP) Out() *G.Node

func (*SimpleMLP) SetVM

func (mlp *SimpleMLP) SetVM(vm G.VM)

func (*SimpleMLP) Vm

func (mlp *SimpleMLP) Vm() G.VM

Jump to

Keyboard shortcuts

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