我想知道 sklearn.neural_network.MLPClassifier 如何初始化权重向量。在文档中 page ,没有提到权重向量默认是如何初始化的。
谢谢。
请您参考如下方法:
看看代码here :
def _init_coef(self, fan_in, fan_out):
if self.activation == 'logistic':
# Use the initialization method recommended by
# Glorot et al.
init_bound = np.sqrt(2. / (fan_in + fan_out))
elif self.activation in ('identity', 'tanh', 'relu'):
init_bound = np.sqrt(6. / (fan_in + fan_out))
else:
# this was caught earlier, just to make sure
raise ValueError("Unknown activation function %s" %
self.activation)
coef_init = self._random_state.uniform(-init_bound, init_bound,
(fan_in, fan_out))
intercept_init = self._random_state.uniform(-init_bound, init_bound,
fan_out)
return coef_init, intercept_init
提到的方法在 paper 中有描述。 : Glorot, X. & Bengio, Y.. (2010)。了解训练深度前馈神经网络的难度。第十三届人工智能与统计国际 session 论文集,PMLR 9:249-256
