pytorch

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MappingFunc

type MappingFunc func(name string) string

MappingFunc is a function that maps a parameter name to another name.

type ParamsProvider

type ParamsProvider[T float.DType] struct {
	// contains filtered or unexported fields
}

ParamsProvider is a provider of parameters for a PyTorch model.

func NewParamsProvider

func NewParamsProvider[T float.DType]() *ParamsProvider[T]

NewParamsProvider returns a new ParamsProvider.

func (*ParamsProvider[T]) Delete

func (p *ParamsProvider[T]) Delete(name string)

Delete deletes a parameter with the given name.

func (*ParamsProvider[T]) Get

func (p *ParamsProvider[T]) Get(name string) []T

Get returns a parameter with the given name.

func (*ParamsProvider[T]) Iterate

func (p *ParamsProvider[T]) Iterate(fn func(name string, data []T) error) error

Iterate iterates over all the parameters in the provider.

func (*ParamsProvider[T]) Load

func (p *ParamsProvider[T]) Load(filename string) error

Load loads parameters from a PyTorch model.

func (*ParamsProvider[T]) Pop

func (p *ParamsProvider[T]) Pop(name string) []T

Pop returns a parameter with the given name and remove it from the params list.

func (*ParamsProvider[T]) Set

func (p *ParamsProvider[T]) Set(name string, data []T)

Set sets a parameter with the given name.

func (*ParamsProvider[T]) WithNameMapping

func (p *ParamsProvider[T]) WithNameMapping(fn MappingFunc) *ParamsProvider[T]

WithNameMapping sets the name mapping function.

func (*ParamsProvider[T]) WithPreProcessing

func (p *ParamsProvider[T]) WithPreProcessing(fn PreProcessingFunc[T]) *ParamsProvider[T]

WithPreProcessing sets the parameters pre-processing function.

type PreProcessingFunc

type PreProcessingFunc[T float.DType] func(params *ParamsProvider[T]) error

PreProcessingFunc is a function that pre-processes parameters before the conversion.

Jump to

Keyboard shortcuts

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