异常解决(二)-- AttributeError: cannot assign module before Module.__init__() call

在调代码的过程中,总会出现各种各样的错误,这次就犯了一个非常愚蠢的错误,在此记录。

AttributeError: cannot assign module before Module.__init__() call

出现这个错误的原因非常简单,调用了自定义的类,但是在自定义的类的__init__函数下面没有写super( XXX, self ).init()

  • 错误案例
    异常解决(二)-- AttributeError: cannot assign module before Module.__init__() call_第1张图片
  • 正确案例
    异常解决(二)-- AttributeError: cannot assign module before Module.__init__() call_第2张图片
    大家在写代码的过程中一定要细心细心细心!
    觉得写的不错的话,欢迎点赞+评论+收藏,这对我帮助很大!
    异常解决(二)-- AttributeError: cannot assign module before Module.__init__() call_第3张图片

你可能感兴趣的:(Bug及问题解决,异常解决,PyTorch,Python)