libtorch

package module
v0.0.0-...-110684a Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

README

libtorch-go

libtorch Go wrapper for model inference

Dependencies

Usage

package main

import (
	"fmt"

	"changkun.de/x/libtorch-go"
)

func main() {
	m := libtorch.NewModel("model.pt")
	defer m.Close()

	nsamples, nfeatures := 2, 4
	x := []float32{1, 2, 3, 4, 1, 2, 3, 4}

	// Output: [13.449158 13.449158]
	fmt.Println(m.Predict(x, nsamples, nfeatures))
}

For more details, see example folder.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

func NewModel

func NewModel(path string) *Model

func (*Model) Close

func (m *Model) Close()

func (*Model) Predict

func (m *Model) Predict(x []float32, nsamples, nfeatures int) []float32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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