def calculate_AFD(self, A, layer):
X = A.copy()
if layer < self.n_layers-1:
if self.activation_function == 'ReLU':
np.place(X, np.array(X > 0), 1)
d = X.clip(0)
elif self.activation_function == 'SoftPlus':
d = 1/(1 + np.exp(-X))
else:
raise NameError(self.activation_function, ' is not in the name list')
else:
d = np.ones_like(X)
return d
评论列表
文章目录