line 947, in __getattr__
raise AttributeError("'{}' object has no attribute '{}'".format(
Attribute Error: 'GCNConv' object has no attribute 'total_ops'
先说一下,我踩过的坑:刚开始参照网上说的,应该是环境问题,就试过好几个版本的环境,倒是花了一天时间,仍然出现这个问题,心都碎了,还把原始虚拟环境搞得稀烂,哈哈哈哈~
最终解决办法:
在utils.py中修改一下dfs_count函数,将total_ops定义进去,完美解决问题
def dfs_count(module: nn.Module, prefix="\t"):
total_ops, total_params = 0, 0
ret_dict = {}
if isinstance(module, GCNConv):
total_ops, total_params = 0, 0
else:
for n, m in module.named_children():
next_dict = {}
if m in handler_collection and not isinstance(m, (nn.Sequential, nn.ModuleList)):
m_ops, m_params = m.total_ops.item(), m.total_params.item()
else:
m_ops, m_params, next_dict = dfs_count(m, prefix=prefix + "\t")
ret_dict[n] = (m_ops, m_params, next_dict)
total_ops += m_ops
total_params += m_params
return total_ops, total_params, ret_dict