scikit如何学习初始化MLPClassifier的权重向量

时间:2017-10-14 23:41:26

标签: python scikit-learn neural-network

我想知道sklearn.neural_network.MLPClassifier如何初始化权重向量。在文档page中,没有提及默认情况下如何初始化权重向量。

感谢。

1 个答案:

答案 0 :(得分:1)

查看代码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

paperGlorot, X. & Bengio, Y.. (2010). Understanding the difficulty of training deep feedforward neural networks. Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, in PMLR 9:249-256

中介绍了上述方法