这是示例代码:
from abc import *
class weightlayer(metaclass=ABCMeta):
def __init_subclass__(cls):
cls.count = 0
def __init__(self):
self.order = cls.count
cls.count += 1
@abstractmethod
def init_weight(self):
pass
class A_layer(weightlayer):
def init_weight(self):
pass
class B_layer(weightlayer):
def init_weight(self):
pass
我已经搜索了很多次,但我找不到解决方案。我的想法不起作用,因为__ init __
函数没有cls
参数。我应该怎么办?