PyTorch NotImplementedError in forward

后端 未结 2 1907
说谎
说谎 2021-01-17 20:12
import torch
import torch.nn as nn

device = torch.device(\'cuda\' if torch.cuda.is_available() else 
\'cpu\')

class Model(nn.Module):
    def __init__(self):
              


        
相关标签:
2条回答
  • 2021-01-17 20:34

    please look carefully at the indentation of your __init__ function: your forward is part of __init__ not part of your module.

    0 讨论(0)
  • 2021-01-17 20:38

    This error happens when you don't implement the required method from super class, in my case, i had typo on the function name forward. I recommend you check your code indentation.

    0 讨论(0)
提交回复
热议问题