Skip to content

pad missing the choice to fill at start or end #567

@ingted

Description

@ingted

In PyTorch:

import torch.nn.functional as F
source = torch.arange(10).unfold(0,3,1)
result = F.pad(input=source, pad=(0,0,1,0), mode='constant', value=0)
source, result

We can decide to pad start, end or both.

image

However in TorchSharp:

let torchAfterUnfoldT = (afterUnfoldT.move Backend.Torch).toTorch() //a tensor
let pad = torch.nn.ConstantPad1d(1L, 0.0)
let padded = pad.forward(torchAfterUnfoldT)
let pdata = padded.data<System.Single>().ToArray()

It always pads both start and end.

image

PS. with pad in DiffSharp, it pads start + end as well

afterUnfoldT.pad(seq [0; 0; 1])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions