Skip to content

nn.Bilinear without bias broken #5990

@kdavis-mozilla

Description

@kdavis-mozilla

System Information

  • OS: OS X 10.13.3
  • PyTorch version: 0.4.0a0+f6274a4
  • How you installed PyTorch (conda, pip, source): source
  • Python version: 3.6.4 (default, Jan 6 2018, 11:51:15)
  • CUDA/cuDNN version: NA (On CPU)
  • GPU models and configuration: NA (On CPU)
  • GCC version (if compiling from source): Apple LLVM version 9.0.0 (clang-900.0.39.2)

Issue Information

I am trying to use nn.Bilinear without a bias, but doing so yields an error.

To reproduce the error run

import torch
import torch.nn as nn

m = nn.Bilinear(20, 30, 40, bias=False)
input1 = torch.randn(128, 20)
input2 = torch.randn(128, 30)
output = m(input1, input2)

This yields the error

(virtualenv) Kellys-MacBook-Pro:sprachspiel kdavis$ python test.py 
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    output = m(input1, input2)
  File "/Users/kdavis/Code/mozilla/sprachspiel/virtualenv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 371, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/kdavis/Code/mozilla/sprachspiel/virtualenv/lib/python3.6/site-packages/torch/nn/modules/linear.py", line 116, in forward
    return F.bilinear(input1, input2, self.weight, self.bias)
  File "/Users/kdavis/Code/mozilla/sprachspiel/virtualenv/lib/python3.6/site-packages/torch/nn/functional.py", line 1004, in bilinear
    return torch._C._VariableFunctions.bilinear(input1, input2, weight, bias)
RuntimeError: dim() called on undefined Tensor

However, running

import torch
import torch.nn as nn

m = nn.Bilinear(20, 30, 40, bias=True)
input1 = torch.randn(128, 20)
input2 = torch.randn(128, 30)
output = m(input1, input2)

works fine.

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