出现 AttributeError: module 'torch.functional' has no attribute 'dropout'
错误通常是因为你正在使用的 PyTorch 版本与你代码中的调用不匹配。在较早的版本中,torch.functional
模块确实没有 dropout
这个函数,而是在 torch.nn.functional
模块中。
解决方法是使用 torch.nn.functional.dropout
而不是 torch.functional.dropout
。