Skip to contents

Applies a bilinear transformation to the incoming data y=x1TAx2+b

Usage

nn_bilinear(in1_features, in2_features, out_features, bias = TRUE)

Arguments

in1_features

size of each first input sample

in2_features

size of each second input sample

out_features

size of each output sample

bias

If set to FALSE, the layer will not learn an additive bias. Default: TRUE

Shape

  • Input1: (N,,Hin1) Hin1=in1\_features and means any number of additional dimensions. All but the last dimension of the inputs should be the same.

  • Input2: (N,,Hin2) where Hin2=in2\_features.

  • Output: (N,,Hout) where Hout=out\_features and all but the last dimension are the same shape as the input.

Attributes

  • weight: the learnable weights of the module of shape (out\_features,in1\_features,in2\_features). The values are initialized from U(k,k), where k=1in1\_features

  • bias: the learnable bias of the module of shape (out\_features). If bias is TRUE, the values are initialized from U(k,k), where k=1in1\_features

Examples

if (torch_is_installed()) {
m <- nn_bilinear(20, 30, 50)
input1 <- torch_randn(128, 20)
input2 <- torch_randn(128, 30)
output <- m(input1, input2)
print(output$size())
}
#> [1] 128  50