pytorch / extension-cpp

C++ extensions in PyTorch
1.02k stars 214 forks source link

AttributeError: 'module' object has no attribute 'Function' #8

Closed anshulpaigwar closed 6 years ago

anshulpaigwar commented 6 years ago

I think there is an typing error in an example code in the tutorials Link on Pytorch website

import math
import torch

# Our module!
import lltm

class LLTMFunction(torch.nn.Function): # <-------------- Here
    @staticmethod
    def forward(ctx, input, weights, bias, old_h, old_cell):
        outputs = lltm.forward(input, weights, bias, old_h, old_cell)
        new_h, new_cell = outputs[:2]
        variables = outputs[1:] + [weights, old_cell]
        ctx.save_for_backward(*variables)

        return new_h, new_cell

torch.nn does not have module Function, It should be torch.autograd.Function

goldsborough commented 6 years ago

True, thanks. Will fix