Deep Learning 学习笔记(二):神经网络Python实现

多层神经网络的Python实现。

代码先贴上,编程的东西不解释。

基本理论参考下一篇:Deep Learning 学习笔记(三):神经网络反向传播算法推导

代码中出现的SupervisedLearningModel、NNLayer和SoftmaxRegression,请参考上一篇笔记:Deep Learning 学习笔记(一)——softmax Regression

多层神经网络:

import numpy as np
from NNBase import NNLayer
from softmax import SoftmaxRegression
from dp.supervised import NNBase
from time import time
class MNN(NNBase.SupervisedLearningModel):
    '''
    classdocs
    '''
    def __init__(self, params):
        '''
        Constructor
        parameters:
            params     - the network configuration, dict
            params.inputSize        - dimension of input features
            params.outputSize        - number of output classes
            params.layerSizes        - an array, sizes of all layer, including all hidden layers and output layer
            params.Lambda            -scaling parameter for l2 weight regularization penalty
            params.activitionFunc    -which type of activation function to use in hidden layers
        
        '''         
        layerSizes =  params['layerSizes']
        self.numLayers = len(layerSizes)
        self.allLayers = []
        self.X=0
        
        #initialize all hidden layers
        inputSize = params['inputSize']
        for i in range(self.numLayers-1):
            layer = NNLayer(inputSize,layerSizes[i],params['Lambda&#
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值