您正在通过调用原始的Conv2D构建来破坏构建(您的构建
self.kernel将被替换,然后
self.kernelA将不再使用,因此反向传播将永远无法实现)。
它还期望有偏差和所有常规内容:
class CustConv2D(Conv2D): def __init__(self, filters, kernel_size, kernelB=None, activation=None, **kwargs): #... #... #don't use bias if you're not defining it: super(CustConv2D, self).__init__(self.num_filters, self.kernel_size, activation=activation, use_bias=False, **kwargs) #bonus: don't forget to add the activation to the call above #it will also replace all your `self.anything` defined before this call def build(self, input_shape): #... #... #don't use bias: self.bias = None #consider the layer built self.built = True #do not destroy your build #comment: super(CustConv2D, self).build(input_shape)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)