Keras Custom Layer ValueError: An operation has `None` for gradient.

后端 未结 2 1365
轮回少年
轮回少年 2021-01-15 20:46

I have created a custom Keras Conv2D layer as follows:

class CustConv2D(Conv2D):

    def __init__(self, filters, kernel_size, kernelB=None, activation=None,         


        
2条回答
  •  耶瑟儿~
    2021-01-15 21:32

    It may be because there are some weights in your code that are defined by not used in the calculation of the output. Thus its gradient wrt the loss is None/undefined.

    A coded out example can be found here: https://github.com/keras-team/keras/issues/12521#issuecomment-496743146

提交回复
热议问题