nn.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Machine-Learning 作者: grasses 项目源码 文件源码
def __init__(self, layers, activation = 'tanh'):
        if activation == 'logistic':
            self.activation = self.logistic
            self.activation_deriv = self.logistic_derivative
        elif activation == 'tanh':
            self.activation = self.tanh
            self.activation_deriv = self.tanh_deriv
        '''
        generate weight matrix with random float
        '''
        self.layers = layers
        self.weights = []
        for i in range(1, len(layers) - 1):
            self.weights.append((2 * np.random.random((layers[i - 1] + 1, layers[i] + 1)) - 1) * 0.25)
            self.weights.append((2 * np.random.random((layers[i] + 1, layers[i + 1])) - 1) * 0.25)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号