1はじめに
機械学習(馬チャイン学習)に基づいて、多くの古典的なアルゴリズムがあるのニューラルネットワークの学習アルゴリズムの深さの深さで最も求められ、主な理由はその敗北のは、ニューラルネットワークに基づくアルゴリズムの李師師アルファ・ドッグためには、実際に深い学習ですアルゴリズム。この記事では、最初に基本的なニューロンを導入し、その後、簡単なパーセプトロン、ニューラルネットワークを多層ように拡張、多層フィードフォワードニューラルネットワーク、他の一般的なニューラルネットワーク、そして奥行きの深い学習ニューラルネットワークに基づいて、紙がZhongjue来る導入し浅く、そして最後のpython自身の言語ペーパーでは、フィードフォワードニューラルネットワーク層を書き込みます。
2ニューロンモデル
ニューロン - これは、生物学的な脳の基本単位です。
このモデルでは、ニューロンは、ニューロンの重み付き合計入力値によって入力信号がニューロンの閾値と比較される受信する、渡すことに接続された入力信号を介して他の神経伝達をnは受信します次いで、「活性化関数」は、処理された出力ニューロンを生成します。
3多層パーセプトロンネットワーク
二つの層からパーセプトロンニューロンを通過した後、入力層、出力層、出力層ニューロンMPに外部入力信号を受信します。
非線形分離可能な問題を解決するために、多層神経機能を使用することを検討してください。各ニューロンと完全に接続下層ニューロン、同一層のニューロン間の接続がない、何の層間接続は存在しません。そのようなニューラルネットワーク構造は、一般的と呼ばれ、「多層フィードフォワードニューラルネットワーク。」
学習ニューラルネットワークは、トレーニングデータに基づいて、各ニューロンのニューロンの閾値と機能「を接続するための権利」を調整するために使用されます。つまり、ニューラルネットワークは、接続重みと閾値の意味合い何かに「学びます」。
4誤差逆伝搬アルゴリズム
ネットワークは、二乗誤差が上であることを意味します:
これは、理由は表現するその強力な能力で、BPニューラルネットワークが頻繁に訓練プロセスのエラーが減少し続けていることフィッティング遭遇したが、テスト・エラーが上昇する可能性が高いでした。BPネットワークの過剰適合を緩和するために使用される2つの戦略があります。第一の戦略は、「早期停止」である:トレーニングセットの勾配を計算するために使用される訓練セットおよび検証セットへのデータは、結合重みと閾値を更新します。第二の戦略は、基本的な考え方は、目的関数の一部にネットワークの複雑さのために記載されているエラーを増加させることであり、「正規」です。
5極小世界最小
若用Ε表示神经网络在训练集上的误差,则它显然关于连接权ω和阈值$\theta$的函数。此时,神经网络的训练过程可看作一个参数寻优的过程,即在参数空间中,寻找最优参数使得E最小。
6 其他常见的神经网络
- RBF网络
- ART网络
- SOM网络
- 级联相关网络
- Elman网络
- Boltzmann机
7 深度学习
典型的深度学习就是很深层的神经网络,显然,对神经网络模型,提高容量的简单方法是增加隐层,隐层多了,相应的神经元连接权、阈值等参数就会更多。模型复杂度也可以通过单纯增加隐层神经元的数目来实现。
深度学习的多隐层堆叠,每层对上一层的输出进行处理的机制,可看作是在对输入信号进行逐层加工,从而把初始的,与输出目标之间联系不太密切的输入表示,转换为与输出目标联系更密切的表示,使得原来仅基于最后一层输出映射难以完成的任务成为可能。换言之,通过多层处理,逐渐将初始的“低层”特征表示转换为“高层”特征表示后,用“简单模型”即可完成复杂的分类任务,由此可将深度学习理解为进行“特征学习”或“表示学习”。
8 使用python制作神经网络
让我们勾勒神经网络类的大概样子,我们知道它应该至少有三个函数:
- 初始化函数——设置输入层节点、隐藏层节点和输出层节点
- 训练——学习给定训练集样本后,优化权重
- 查询——给定输入,从输出节点给出答案
# 神经网络类 class neuralNetwork: # 初始化网络 def __init__(self, inputnodes, hiddennodes, outputnodes, learningrate): self.inodes = inputnodes self.hnodes = hiddennodes self.onodes = outputnodes #链接权重矩阵 self.wih = numpy.random.normal(0.0, pow(self.inodes, -0.5), (self.hnodes, self.inodes)) self.who = numpy.random.normal(0.0, pow(self.hnodes, -0.5), (self.onodes, self.hnodes)) # learning rate self.lr = learningrate self.activation_function = lambda x: 1/(1+numpy.exp(-x)) pass # 训练网络 def train(self, inputs_list, targets_list): # convert inputs list to 2d array inputs = numpy.array(inputs_list, ndmin=2).T targets = numpy.array(targets_list, ndmin=2).T # calculate signals into hidden layer hidden_inputs = numpy.dot(self.wih, inputs) # calculate the signals emerging from hidden layer hidden_outputs = self.activation_function(hidden_inputs) # calculate signals into final output layer final_inputs = numpy.dot(self.who, hidden_outputs) # calculate the signals emerging from final output layer final_outputs = self.activation_function(final_inputs) # output layer error is the (target - actual) output_errors = targets - final_outputs # hidden layer error is the output_errors, split by weights, recombined at hidden nodes hidden_errors = numpy.dot(self.who.T, output_errors) # update the weights for the links between the hidden and output layers self.who += self.lr * numpy.dot((output_errors * final_outputs * (1.0 - final_outputs)), numpy.transpose(hidden_outputs)) # update the weights for the links between the input and hidden layers self.wih += self.lr * numpy.dot((hidden_errors * hidden_outputs * (1.0 - hidden_outputs)), numpy.transpose(inputs)) pass # 查询网络 def query(self, inputs_list): # convert inputs list to 2d array inputs = numpy.array(inputs_list, ndmin=2).T # calculate signals into hidden layer hidden_inputs = numpy.dot(self.wih, inputs) # calculate the signals emerging from hidden layer hidden_outputs = self.activation_function(hidden_inputs) # calculate signals into final output layer final_inputs = numpy.dot(self.who, hidden_outputs) # calculate the signals emerging from final output layer final_outputs = self.activation_function(final_inputs) return final_outputs
手写数字的数据集MNIST
training_data_file = open("mnist_dataset/mnist_train.csv", 'r') training_data_list = training_data_file.readlines() training_data_file.close()
训练数据集
epochs = 5 for e in range(epochs): # go through all records in the training data set for record in training_data_list: # split the record by the ',' commas all_values = record.split(',') # scale and shift the inputs # 输入值需要避免0,输出值需要避免1 inputs = (numpy.asfarray(all_values[1:]) / 255.0 * 0.99) + 0.01 # create the target output values (all 0.01, except the desired label which is 0.99) targets = numpy.zeros(output_nodes) + 0.01 # all_values[0] is the target label for this record targets[int(all_values[0])] = 0.99 n.train(inputs, targets) pass pass
测试数据集
test_data_file = open("mnist_dataset/mnist_test.csv", 'r') test_data_list = test_data_file.readlines() test_data_file.close() scorecard = [] # go through all the records in the test data set for record in test_data_list: # split the record by the ',' commas all_values = record.split(',') # correct answer is first value correct_label = int(all_values[0]) # scale and shift the inputs inputs = (numpy.asfarray(all_values[1:]) / 255.0 * 0.99) + 0.01 # query the network outputs = n.query(inputs) # the index of the highest value corresponds to the label label = numpy.argmax(outputs) # append correct or incorrect to list if (label == correct_label): # network's answer matches correct answer, add 1 to scorecard scorecard.append(1) else: # network's answer doesn't match correct answer, add 0 to scorecard scorecard.append(0) pass pass # calculate the performance score, the fraction of correct answers scorecard_array = numpy.asarray(scorecard) print ("performance = ", scorecard_array.su m() / scorecard_array.size)