Documentation ¶
Index ¶
- func AlexNet(p *nn.Path, nclasses int64) ts.ModuleT
- func Augmentation(t *ts.Tensor, flip bool, crop int64, cutout int64) *ts.Tensor
- func DenseNet121(p *nn.Path, nclasses int64) ts.ModuleT
- func DenseNet161(p *nn.Path, nclasses int64) ts.ModuleT
- func DenseNet169(p *nn.Path, nclasses int64) ts.ModuleT
- func DenseNet201(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB0(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB1(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB2(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB3(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB4(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB5(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB6(p *nn.Path, nclasses int64) ts.ModuleT
- func EfficientNetB7(p *nn.Path, nclasses int64) ts.ModuleT
- func InceptionV3(p *nn.Path, nclasses int64) ts.ModuleT
- func Load(path string) (*ts.Tensor, error)
- func LoadAndResize(path string, outW int64, outH int64) (*ts.Tensor, error)
- func LoadDir(dir string, outW int64, outH int64) (*ts.Tensor, error)
- func MobileNetV2(p *nn.Path, nclasses int64) ts.ModuleT
- func RandomCrop(t *ts.Tensor, pad int64) *ts.Tensor
- func RandomCutout(t *ts.Tensor, sz int64) *ts.Tensor
- func RandomFlip(t *ts.Tensor) *ts.Tensor
- func ResNet101(path *nn.Path, numClasses int64) ts.ModuleT
- func ResNet101NoFinalLayer(path *nn.Path) ts.ModuleT
- func ResNet150NoFinalLayer(path *nn.Path) ts.ModuleT
- func ResNet152(path *nn.Path, numClasses int64) ts.ModuleT
- func ResNet18(path *nn.Path, numClasses int64) nn.FuncT
- func ResNet18NoFinalLayer(path *nn.Path) nn.FuncT
- func ResNet34(path *nn.Path, numClasses int64) nn.FuncT
- func ResNet34NoFinalLayer(path *nn.Path) nn.FuncT
- func ResNet50(path *nn.Path, numClasses int64) ts.ModuleT
- func ResNet50NoFinalLayer(path *nn.Path) ts.ModuleT
- func Resize(t *ts.Tensor, outW int64, outH int64) (*ts.Tensor, error)
- func ResizePreserveAspectRatio(t *ts.Tensor, outW int64, outH int64) (*ts.Tensor, error)
- func Save(tensor *ts.Tensor, path string) error
- func SqueezeNetV1_0(p *nn.Path, nclasses int64) ts.ModuleT
- func SqueezeNetV1_1(p *nn.Path, nclasses int64) ts.ModuleT
- func VGG11(path *nn.Path, nclasses int64) *nn.SequentialT
- func VGG11BN(path *nn.Path, nclasses int64) *nn.SequentialT
- func VGG13(path *nn.Path, nclasses int64) *nn.SequentialT
- func VGG13BN(path *nn.Path, nclasses int64) *nn.SequentialT
- func VGG16(path *nn.Path, nclasses int64) *nn.SequentialT
- func VGG16BN(path *nn.Path, nclasses int64) *nn.SequentialT
- func VGG19(path *nn.Path, nclasses int64) *nn.SequentialT
- func VGG19BN(path *nn.Path, nclasses int64) *nn.SequentialT
- type BlockArgs
- type Dataset
- type ImageNet
- func (in *ImageNet) ClassCount() int64
- func (in *ImageNet) Classes() []string
- func (in *ImageNet) LoadFromDir(path string) (*Dataset, error)
- func (in *ImageNet) LoadImage(path string) (*ts.Tensor, error)
- func (in *ImageNet) LoadImageAndResize(path string, w, h int64) (*ts.Tensor, error)
- func (in *ImageNet) LoadImageAndResize224(path string) (*ts.Tensor, error)
- func (in *ImageNet) Normalize(tensor *ts.Tensor) (*ts.Tensor, error)
- func (in *ImageNet) SaveImage(tensor *ts.Tensor, path string) error
- func (in *ImageNet) Top(input *ts.Tensor, k int64) []TopItem
- func (in *ImageNet) UnNormalize(tensor *ts.Tensor) (*ts.Tensor, error)
- type TopItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load loads an image from a file.
On success returns a tensor of shape [channel, height, width].
func LoadAndResize ¶
LoadAndResize loads and resizes an image, preserve the aspect ratio by taking a center crop.
func RandomCrop ¶
Pad the image using reflections and take some random crops. This expects a 4 dimension NCHW tensor and returns a tensor with an identical shape.
func RandomCutout ¶
Applies cutout: randomly remove some square areas in the original images. https://arxiv.org/abs/1708.04552
func RandomFlip ¶
RandomFlip randomly applies horizontal flips This expects a 4 dimension NCHW tensor and returns a tensor with an identical shape.
func ResNet101NoFinalLayer ¶
ResNet101 creates a ResNet-101 model without final fully connfected layer.
func ResNet150NoFinalLayer ¶
ResNet150 creates a ResNet-150 model without final fully connfected layer.
func ResNet18NoFinalLayer ¶
ResNet18 creates a ResNet-18 model without final fully connfected layer.
func ResNet34NoFinalLayer ¶
ResNet34 creates a ResNet-34 model without final fully connfected layer.
func ResNet50NoFinalLayer ¶
ResNet50 creates a ResNet-50 model without final fully connfected layer.
func Resize ¶
Resize resizes an image.
This expects as input a tensor of shape [channel, height, width] and returns a tensor of shape [channel, out_h, out_w].
func ResizePreserveAspectRatio ¶
ResizePreserveAspectRatio resizes an image, preserve the aspect ratio by taking a center crop.
This expects as input a tensor of shape [channel, height, width] and returns
Types ¶
type Dataset ¶
type Dataset struct { TrainImages *ts.Tensor TrainLabels *ts.Tensor TestImages *ts.Tensor TestLabels *ts.Tensor Labels int64 }
func LoadMNISTDir ¶
LoadMNISTDir loads all MNIST data from a given directory to Dataset
type ImageNet ¶
type ImageNet struct {
// contains filtered or unexported fields
}
func NewImageNet ¶
func NewImageNet() *ImageNet
func (*ImageNet) ClassCount ¶
func (*ImageNet) LoadFromDir ¶
LoadFromDir loads a dataset from a directory.
NOTE: This assumes that the directory contains two subdirectories named train and val. In each of these datasets, there should be a subdirectory per class named in the same way. The ImageNet normalization is applied, image are resized to 224x224.
func (*ImageNet) LoadImage ¶
Load loads an image from a file and applies the ImageNet normalization.
func (*ImageNet) LoadImageAndResize ¶
LoadImageAndResize loads an image from a file and resize it to the specified width and height.
NOTE: This will apply the ImageNet normalization.
func (*ImageNet) LoadImageAndResize224 ¶
LoadImageAndResize224 loads an image from a file and resize it to 224x224.
NOTE: This will apply the ImageNet normalization.
func (*ImageNet) SaveImage ¶
SaveImage saves a tensor image to a path.
NOTE: This will carry out the ImageNet unnormalization.