【翻译自: How to Manually Optimize Neural Network Models】

【说明:Jason Brownlee PhD大神的文章个人很喜欢,所以闲暇时间里会做一点翻译和学习实践的工作,这里是相应工作的实践记录,希望能帮到有需要的人!】

深度学习神经网络模型使用随机梯度下降优化算法拟合训练数据。使用误差算法的反向传播对模型权重进行更新。精心选择了优化和权重更新算法的组合,这是已知的最适合神经网络的方法。但是,可以使用替代的优化算法来将神经网络模型拟合到训练数据集。这对于了解更多有关神经网络的功能以及应用机器学习中优化的核心性质可能是一个有用的练习。具有非常规模型架构和不可微分传递函数的神经网络也可能需要它。

在本教程中,您将发现如何手动优化神经网络模型的权重,完成本教程后,您将知道:

如何从头开始为神经网络模型开发正向推理过程。
如何为二进制分类优化Perceptron模型的权重。
如何使用随机爬山优化多层感知器模型的权重。

教程概述

本教程分为三个部分:他们是:

优化神经网络
优化感知器模型
优化多层感知器

优化神经网络

深度学习或神经网络是机器学习的一种灵活类型。它们是由受大脑结构和功能启发的节点和层组成的模型。神经网络模型的工作原理是,将给定的输入向量传播到一个或多个层中,以产生可以解释用于分类或回归预测建模的数字输出。通过反复将模型暴露于输入和输出示例,并调整权重以使模型输出与预期输出的误差最小,来训练模型。这称为随机梯度下降优化算法。使用微积分中的特定规则调整模型的权重,该规则将误差按比例分配给网络中的每个权重。这称为反向传播算法。使用反向传播进行权重更新的随机梯度下降优化算法是训练神经网络模型的最佳方法。但是,它不是训练神经网络的唯一方法。可以使用任何任意的优化算法来训练神经网络模型。也就是说,我们可以定义一个神经网络模型架构,并使用给定的优化算法为该模型找到一组权重,从而使预测误差最小或分类精度最大。与使用反向传播的随机梯度下降相比,使用备用优化算法的平均效率较低。但是,在某些特定情况下,例如非标准网络体系结构或非差分传递函数,它可能更有效。在训练机器学习算法(特别是神经网络)中展示优化的中心性质也可能是一个有趣的练习。接下来,让我们探讨如何使用随机爬山训练称为Perceptron模型的简单单节点神经网络。

优化感知器模型

Perceptron算法是最简单的人工神经网络类型。它是单个神经元的模型,可用于两类分类问题,并为以后开发更大的网络提供了基础。在本节中,我们将优化Perceptron神经网络模型的权重。首先,让我们定义一个综合二进制分类问题,我们可以将其用作优化模型的重点。我们可以使用make_classification()函数来定义一个包含1,000行和五个输入变量的二进制分类问题。下面的示例创建数据集并总结数据的形状。

# define a binary classification dataset
from sklearn.datasets import make_classification
# define dataset
X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
# summarize the shape of the dataset
print(X.shape, y.shape)

运行示例将打印创建的数据集的形状,从而确认我们的期望。

(1000, 5) (1000,)

接下来,我们需要定义一个Perceptron模型。Perceptron模型只有一个节点,该节点对数据集中的每一列都有一个输入权重。每个输入都乘以其相应的权重以得出加权总和,然后加上偏差权重,就像回归模型中的拦截系数一样。该加权和称为激活。最后,激活被解释并用于预测类别标签,正激活为1,负激活为0。在优化模型权重之前,我们必须开发模型以及对模型如何工作的信心。首先定义一个解释模型激活的函数。这称为激活函数或传递函数。后者的名称比较传统,是我的偏爱。下面的transfer()函数接受模型的激活并返回一个类标签,对于正或零激活,返回class = 1,对于负激活,返回class = 0。这称为步进传递函数。

# transfer function
def transfer(activation):if activation >= 0.0:return 1return 0

接下来,我们可以开发一个函数,该函数针对来自数据集的给定输入数据行计算模型的激活。此函数将获取数据行和模型的权重,并加上偏差权重来计算输入的增量总和。下面的激活()函数实现了这一点。注意:我们使用的是简单的Python列表和命令式编程样式,而不是NumPy数组或列表压缩,目的是使代码对Python初学者注意改变性。随时进行进行优化,并在下面的注释中 发布您的代码。

# activation function
def activate(row, weights):# add the bias, the last weightactivation = weights[-1]# add the weighted inputfor i in range(len(row)):activation += weights[i] * row[i]return activation

接下来,我们可以一起使用activate()和transfer()函数来生成给定数据行的预测。 下面的predict_row()函数实现了这一点。

# use model weights to predict 0 or 1 for a given row of data
def predict_row(row, weights):# activate for inputactivation = activate(row, weights)# transfer for activationreturn transfer(activation)

接下来,我们可以为给定数据集中的每一行调用predict_row()函数。 下面的predict_dataset()函数实现了这一点。同样,我们有意使用简单的命令式编码风格来提高可读性,而不是列表压缩。

# use model weights to generate predictions for a dataset of rows
def predict_dataset(X, weights):yhats = list()for row in X:yhat = predict_row(row, weights)yhats.append(yhat)return yhats

最后,我们可以使用该模型对综合数据集进行预测,以确认其均正常工作。我们可以使用rand()函数生成一组随机的模型权重。回想一下,我们需要为每个输入(此数据集中的五个输入)分配一个权重,并为偏置权重添加一个额外的权重。

# define dataset
X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
# determine the number of weights
n_weights = X.shape[1] + 1
# generate random weights
weights = rand(n_weights)

然后,我们可以将这些权重与数据集一起使用进行预测。

# generate predictions for dataset
yhat = predict_dataset(X, weights)

我们可以评估这些预测的分类准确性。

# calculate accuracy
score = accuracy_score(y, yhat)
print(score)

我们可以将所有这些结合在一起,并演示用于分类的简单Perceptron模型。 下面列出了完整的示例。

# simple perceptron model for binary classification
from numpy.random import rand
from sklearn.datasets import make_classification
from sklearn.metrics import accuracy_score# transfer function
def transfer(activation):if activation >= 0.0:return 1return 0# activation function
def activate(row, weights):# add the bias, the last weightactivation = weights[-1]# add the weighted inputfor i in range(len(row)):activation += weights[i] * row[i]return activation# use model weights to predict 0 or 1 for a given row of data
def predict_row(row, weights):# activate for inputactivation = activate(row, weights)# transfer for activationreturn transfer(activation)# use model weights to generate predictions for a dataset of rows
def predict_dataset(X, weights):yhats = list()for row in X:yhat = predict_row(row, weights)yhats.append(yhat)return yhats# define dataset
X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
# determine the number of weights
n_weights = X.shape[1] + 1
# generate random weights
weights = rand(n_weights)
# generate predictions for dataset
yhat = predict_dataset(X, weights)
# calculate accuracy
score = accuracy_score(y, yhat)
print(score)

运行示例会为训练数据集中的每个示例生成一个预测,然后打印该预测的分类准确性。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。 考虑运行该示例几次并比较平均结果。

在给定一组随机权重和每个类中具有相同数量示例的数据集的情况下,我们可以期望达到约50%的准确性,在这种情况下,这大约就是我们看到的结果。

0.548

现在,我们可以优化数据集的权重,以在此数据集上实现良好的准确性。

首先,我们需要将数据集分为训练集和测试集。 重要的是要保留一些在优化模型中不使用的数据,以便在用于对新数据进行预测时,我们可以对模型的性能进行合理的估计。

我们将67%的数据用于训练,其余33%的数据用作评估模型性能的测试集。

# split into train test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)

接下来,我们可以开发一种随机爬山算法。

优化算法需要目标函数进行优化。 它必须具有一组权重,并返回与更好的模型相对应的最小或最大分数。

在这种情况下,我们将使用给定的权重集评估模型的准确性,并返回必须最大化的分类准确性。

给定数据集和一组权重,下面的Objective()函数将实现此目的,并返回模型的准确性

# objective function
def objective(X, y, weights):# generate predictions for datasetyhat = predict_dataset(X, weights)# calculate accuracyscore = accuracy_score(y, yhat)return score

接下来,我们可以定义随机爬山算法。

该算法将需要一个初始解(例如随机权重),并将迭代地不断对解做一些细微更改并检查它是否导致性能更好的模型。 当前解决方案的更改量由step_size超参数控制。 此过程将继续进行固定数量的迭代,也作为超参数提供。

下面的hillclimbing()函数以数据集,目标函数,初始解和超参数为参数来实现此目的,并返回找到的最佳权重集和估计的性能。

# hill climbing local search algorithm
def hillclimbing(X, y, objective, solution, n_iter, step_size):# evaluate the initial pointsolution_eval = objective(X, y, solution)# run the hill climbfor i in range(n_iter):# take a stepcandidate = solution + randn(len(solution)) * step_size# evaluate candidate pointcandidte_eval = objective(X, y, candidate)# check if we should keep the new pointif candidte_eval >= solution_eval:# store the new pointsolution, solution_eval = candidate, candidte_eval# report progressprint('>%d %.5f' % (i, solution_eval))return [solution, solution_eval]

然后我们可以调用此函数,传入一组权重作为初始解,输入训练数据集作为针对模型进行优化的数据集。

# define the total iterations
n_iter = 1000
# define the maximum step size
step_size = 0.05
# determine the number of weights
n_weights = X.shape[1] + 1
# define the initial solution
solution = rand(n_weights)
# perform the hill climbing search
weights, score = hillclimbing(X_train, y_train, objective, solution, n_iter, step_size)
print('Done!')
print('f(%s) = %f' % (weights, score))

最后,我们可以评估测试数据集上的最佳模型并报告性能。

# generate predictions for the test dataset
yhat = predict_dataset(X_test, weights)
# calculate accuracy
score = accuracy_score(y_test, yhat)
print('Test Accuracy: %.5f' % (score * 100))

综上所述,下面列出了在合成二进制优化数据集上优化Perceptron模型权重的完整示例。

# hill climbing to optimize weights of a perceptron model for classification
from numpy import asarray
from numpy.random import randn
from numpy.random import rand
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score# transfer function
def transfer(activation):if activation >= 0.0:return 1return 0# activation function
def activate(row, weights):# add the bias, the last weightactivation = weights[-1]# add the weighted inputfor i in range(len(row)):activation += weights[i] * row[i]return activation# # use model weights to predict 0 or 1 for a given row of data
def predict_row(row, weights):# activate for inputactivation = activate(row, weights)# transfer for activationreturn transfer(activation)# use model weights to generate predictions for a dataset of rows
def predict_dataset(X, weights):yhats = list()for row in X:yhat = predict_row(row, weights)yhats.append(yhat)return yhats# objective function
def objective(X, y, weights):# generate predictions for datasetyhat = predict_dataset(X, weights)# calculate accuracyscore = accuracy_score(y, yhat)return score# hill climbing local search algorithm
def hillclimbing(X, y, objective, solution, n_iter, step_size):# evaluate the initial pointsolution_eval = objective(X, y, solution)# run the hill climbfor i in range(n_iter):# take a stepcandidate = solution + randn(len(solution)) * step_size# evaluate candidate pointcandidte_eval = objective(X, y, candidate)# check if we should keep the new pointif candidte_eval >= solution_eval:# store the new pointsolution, solution_eval = candidate, candidte_eval# report progressprint('>%d %.5f' % (i, solution_eval))return [solution, solution_eval]# define dataset
X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
# split into train test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
# define the total iterations
n_iter = 1000
# define the maximum step size
step_size = 0.05
# determine the number of weights
n_weights = X.shape[1] + 1
# define the initial solution
solution = rand(n_weights)
# perform the hill climbing search
weights, score = hillclimbing(X_train, y_train, objective, solution, n_iter, step_size)
print('Done!')
print('f(%s) = %f' % (weights, score))
# generate predictions for the test dataset
yhat = predict_dataset(X_test, weights)
# calculate accuracy
score = accuracy_score(y_test, yhat)
print('Test Accuracy: %.5f' % (score * 100))

每次对模型进行改进时,运行示例将报告迭代次数和分类准确性。

搜索结束时,报告训练数据集上最佳权重集的性能,并计算和报告测试数据集上相同模型的性能。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。 考虑运行该示例几次并比较平均结果。

在这种情况下,我们可以看到优化算法找到了一组权重,这些权重在训练数据集上达到了约88.5%的精度,在测试数据集上达到了约81.8%的精度。

>111 0.88060
>119 0.88060
>126 0.88209
>134 0.88209
>205 0.88209
>262 0.88209
>280 0.88209
>293 0.88209
>297 0.88209
>336 0.88209
>373 0.88209
>437 0.88358
>463 0.88507
>630 0.88507
>701 0.88507
Done!
f([ 0.0097317 0.13818088 1.17634326 -0.04296336 0.00485813 -0.14767616]) = 0.885075
Test Accuracy: 81.81818

既然我们熟悉了如何手动优化Perceptron模型的权重,让我们看一下如何扩展示例以优化多层Perceptron(MLP)模型的权重。

优化多层感知器

多层感知器(MLP)模型是具有一层或多层的神经网络,其中每一层都有一个或多个节点。它是Perceptron模型的扩展,并且可能是使用最广泛的神经网络(深度学习)模型。在本节中,我们将基于在上一节中学到的知识来优化具有任意数量的层和每层节点的MLP模型的权重。首先,我们将开发模型并使用随机权重对其进行测试,然后使用随机爬坡优化模型权重。使用MLP进行二进制分类时,通常会使用S型传递函数(也称为逻辑函数),而不是Perceptron中使用的步进传递函数。此函数输出表示二项式概率分布的0-1之间的实数值,例如一个示例属于class = 1的概率。下面的transfer()函数实现了这一点。

# transfer function
def transfer(activation):# sigmoid transfer functionreturn 1.0 / (1.0 + exp(-activation))

我们可以使用上一部分中相同的activate()函数。 在这里,我们将使用它来计算给定层中每个节点的激活。必须使用更详尽的版本替换预报函数(predict_row())。该函数获取一行数据和网络,并返回网络的输出。

我们将网络定义为列表列表。 每个层将是节点列表,每个节点将是权重列表或权重数组。要计算网络的预测,我们只需枚举层,然后枚举节点,然后计算每个节点的激活和传输输出。 在这种情况下,我们将对网络中的所有节点使用相同的传递函数,尽管并非必须如此。对于具有多层以上的网络,上一层的输出用作下一层中每个节点的输入。 然后返回网络中最后一层的输出。下面的predict_row()函数实现了这一点。

# activation function for a network
def predict_row(row, network):inputs = row# enumerate the layers in the network from input to outputfor layer in network:new_inputs = list()# enumerate nodes in the layerfor node in layer:# activate the nodeactivation = activate(inputs, node)# transfer activationoutput = transfer(activation)# store outputnew_inputs.append(output)# output from this layer is input to the next layerinputs = new_inputsreturn inputs[0]

就是这样。最后,我们需要定义要使用的网络。例如,我们可以定义具有单个隐藏层和单个节点的MLP,如下所示:

# create a one node network
node = rand(n_inputs + 1)
layer = [node]
network = [layer]

尽管具有S型传递函数,但实际上是Perceptron。 很无聊。让我们定义一个具有一个隐藏层和一个输出层的MLP。 第一个隐藏层将有10个节点,每个节点将从数据集中获取输入模式(例如5个输入)。 输出层将具有一个节点,该节点从第一隐藏层的输出中获取输入,然后输出预测。

# one hidden layer and an output layer
n_hidden = 10
hidden1 = [rand(n_inputs + 1) for _ in range(n_hidden)]
output1 = [rand(n_hidden + 1)]
network = [hidden1, output1]

然后,我们可以使用该模型对数据集进行预测。

# generate predictions for dataset
yhat = predict_dataset(X, network)

在计算分类准确性之前,我们必须将预测取整为类别标签0和1。

# round the predictions
yhat = [round(y) for y in yhat]
# calculate accuracy
score = accuracy_score(y, yhat)
print(score)

综上所述,下面列出了在我们的合成二进制分类数据集中评估具有随机初始权重的MLP的完整示例。

# develop an mlp model for classification
from math import exp
from numpy.random import rand
from sklearn.datasets import make_classification
from sklearn.metrics import accuracy_score# transfer function
def transfer(activation):# sigmoid transfer functionreturn 1.0 / (1.0 + exp(-activation))# activation function
def activate(row, weights):# add the bias, the last weightactivation = weights[-1]# add the weighted inputfor i in range(len(row)):activation += weights[i] * row[i]return activation# activation function for a network
def predict_row(row, network):inputs = row# enumerate the layers in the network from input to outputfor layer in network:new_inputs = list()# enumerate nodes in the layerfor node in layer:# activate the nodeactivation = activate(inputs, node)# transfer activationoutput = transfer(activation)# store outputnew_inputs.append(output)# output from this layer is input to the next layerinputs = new_inputsreturn inputs[0]# use model weights to generate predictions for a dataset of rows
def predict_dataset(X, network):yhats = list()for row in X:yhat = predict_row(row, network)yhats.append(yhat)return yhats# define dataset
X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
# determine the number of inputs
n_inputs = X.shape[1]
# one hidden layer and an output layer
n_hidden = 10
hidden1 = [rand(n_inputs + 1) for _ in range(n_hidden)]
output1 = [rand(n_hidden + 1)]
network = [hidden1, output1]
# generate predictions for dataset
yhat = predict_dataset(X, network)
# round the predictions
yhat = [round(y) for y in yhat]
# calculate accuracy
score = accuracy_score(y, yhat)
print(score)

运行示例将为训练数据集中的每个示例生成一个预测,然后打印该预测的分类准确性。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。 考虑运行该示例几次并比较平均结果。

再一次,在给定一组随机权重和每个类中具有相同数量示例的数据集的情况下,我们可以期望达到约50%的准确性,在这种情况下,这大约就是我们看到的结果。

0.499

接下来,我们可以将随机爬山算法应用于数据集。它与将爬坡应用于Perceptron模型非常相似,除了在这种情况下,需要对网络中的所有权重进行修改。为此,我们将开发一个新功能,该功能可创建网络副本并在制作副本时更改网络中的每个权重。下面的step()函数实现了这一点。

# take a step in the search space
def step(network, step_size):new_net = list()# enumerate layers in the networkfor layer in network:new_layer = list()# enumerate nodes in this layerfor node in layer:# mutate the nodenew_node = node.copy() + randn(len(node)) * step_size# store node in layernew_layer.append(new_node)# store layer in networknew_net.append(new_layer)return new_net

修改网络中的所有权重都是很积极的。搜索空间中较不积极的步骤可能是对模型中权重的子集进行较小的更改,可能由超参数控制。 这留作扩展。然后,我们可以从hillclimbing()函数中调用此新的step()函数。

# hill climbing local search algorithm
def hillclimbing(X, y, objective, solution, n_iter, step_size):# evaluate the initial pointsolution_eval = objective(X, y, solution)# run the hill climbfor i in range(n_iter):# take a stepcandidate = step(solution, step_size)# evaluate candidate pointcandidte_eval = objective(X, y, candidate)# check if we should keep the new pointif candidte_eval >= solution_eval:# store the new pointsolution, solution_eval = candidate, candidte_eval# report progressprint('>%d %f' % (i, solution_eval))return [solution, solution_eval]

综上所述,下面列出了应用随机爬坡优化用于二进制分类的MLP模型权重的完整示例。

# stochastic hill climbing to optimize a multilayer perceptron for classification
from math import exp
from numpy.random import randn
from numpy.random import rand
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score# transfer function
def transfer(activation):# sigmoid transfer functionreturn 1.0 / (1.0 + exp(-activation))# activation function
def activate(row, weights):# add the bias, the last weightactivation = weights[-1]# add the weighted inputfor i in range(len(row)):activation += weights[i] * row[i]return activation# activation function for a network
def predict_row(row, network):inputs = row# enumerate the layers in the network from input to outputfor layer in network:new_inputs = list()# enumerate nodes in the layerfor node in layer:# activate the nodeactivation = activate(inputs, node)# transfer activationoutput = transfer(activation)# store outputnew_inputs.append(output)# output from this layer is input to the next layerinputs = new_inputsreturn inputs[0]# use model weights to generate predictions for a dataset of rows
def predict_dataset(X, network):yhats = list()for row in X:yhat = predict_row(row, network)yhats.append(yhat)return yhats# objective function
def objective(X, y, network):# generate predictions for datasetyhat = predict_dataset(X, network)# round the predictionsyhat = [round(y) for y in yhat]# calculate accuracyscore = accuracy_score(y, yhat)return score# take a step in the search space
def step(network, step_size):new_net = list()# enumerate layers in the networkfor layer in network:new_layer = list()# enumerate nodes in this layerfor node in layer:# mutate the nodenew_node = node.copy() + randn(len(node)) * step_size# store node in layernew_layer.append(new_node)# store layer in networknew_net.append(new_layer)return new_net# hill climbing local search algorithm
def hillclimbing(X, y, objective, solution, n_iter, step_size):# evaluate the initial pointsolution_eval = objective(X, y, solution)# run the hill climbfor i in range(n_iter):# take a stepcandidate = step(solution, step_size)# evaluate candidate pointcandidte_eval = objective(X, y, candidate)# check if we should keep the new pointif candidte_eval >= solution_eval:# store the new pointsolution, solution_eval = candidate, candidte_eval# report progressprint('>%d %f' % (i, solution_eval))return [solution, solution_eval]# define dataset
X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
# split into train test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
# define the total iterations
n_iter = 1000
# define the maximum step size
step_size = 0.1
# determine the number of inputs
n_inputs = X.shape[1]
# one hidden layer and an output layer
n_hidden = 10
hidden1 = [rand(n_inputs + 1) for _ in range(n_hidden)]
output1 = [rand(n_hidden + 1)]
network = [hidden1, output1]
# perform the hill climbing search
network, score = hillclimbing(X_train, y_train, objective, network, n_iter, step_size)
print('Done!')
print('Best: %f' % (score))
# generate predictions for the test dataset
yhat = predict_dataset(X_test, network)
# round the predictions
yhat = [round(y) for y in yhat]
# calculate accuracy
score = accuracy_score(y_test, yhat)
print('Test Accuracy: %.5f' % (score * 100))

每次对模型进行改进时,运行示例将报告迭代次数和分类准确性。

搜索结束时,报告训练数据集上最佳权重集的性能,并计算和报告测试数据集上相同模型的性能。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。 考虑运行该示例几次并比较平均结果。

在这种情况下,我们可以看到优化算法找到了一组权重,这些权重在训练数据集上达到约87.3%的准确性,在测试数据集上达到约85.1%的准确性。

>55 0.755224
>56 0.765672
>59 0.794030
>66 0.805970
>77 0.835821
>120 0.838806
>165 0.840299
>188 0.841791
>218 0.846269
>232 0.852239
>237 0.852239
>239 0.855224
>292 0.867164
>368 0.868657
>823 0.868657
>852 0.871642
>889 0.871642
>892 0.871642
>992 0.873134
Done!
Best: 0.873134
Test Accuracy: 85.15152

如何手动优化神经网络模型相关推荐

  1. 独家 | 如何手动优化神经网络模型(附链接)

    翻译:陈丹 校对:车前子 本文约5400字,建议阅读15分钟 本文是一个教授如何优化神经网络模型的基础教程,提供了具体的实战代码供读者学习和实践. 标签:神经网络优化 深度学习的神经网络是采用随机梯度 ...

  2. 第14课:项目实战——深度优化你的神经网络模型

    上一篇给出了构建神经网络模型时的一些实用建议,涉及到评估模型.训练/验证/测试集.贝叶斯最优误差和人类表现水平.错误分析等内容.掌握这些知识对优化神经网络模型非常有用. 本文将继续使用第9课中的项目, ...

  3. PyTorch | (4)神经网络模型搭建和参数优化

    PyTorch | (1)初识PyTorch PyTorch | (2)PyTorch 入门-张量 PyTorch | (3)Tensor及其基本操作 PyTorch | (4)神经网络模型搭建和参数 ...

  4. trainlm算法c语言,粒子群优化的BP神经网络模型对C、Mn两种元素收得率的预测

    粒子群优化的BP神经网络模型对C.Mn两种元素收得率的预测 来源:用户上传 作者: 摘 要:本文首先对数据进行处理,利用收得率公式求出历史收得率:并利用已知的影响元素收得率的主要影响因素结合BP神经网 ...

  5. 神经网络模型优化方法(缓解过拟合)

    转自:https://blog.csdn.net/chenyukuai6625/article/details/76922840 一.背景简介    在深度学习和机器学习的各种模型训练过程中,在训练数 ...

  6. 清华大学张长水教授:神经网络模型的结构优化

    清华大学张长水教授:神经网络模型的结构优化 转自搜狐:▼▼▼▼点击下方原标题跳转至原文 原标题:清华大学张长水教授:神经网络模型的结构优化(附PPT) 张长水教授,清华大学自动化系教授.博士生导师,智 ...

  7. VALSE 2017 | 神经网络模型压缩优化方法

    ​本文 首发在个人微信公众号:计算机视觉life上. 近年来,深度神经网络在计算机视觉.语音识别等领域取得了巨大成功.为了完成更加复杂的信息处理任务,深度神经网络变得越来越深,也使得其计算量越来越大. ...

  8. 神经网络模型中class的forward函数何时调用_总结深度学习PyTorch神经网络箱使用...

    ↑ 点击蓝字 关注极市平台来源丨计算机视觉联盟编辑丨极市平台 极市导读 本文介绍了Pytorch神经网络箱的使用,包括核心组件.神经网络实例.构建方法.优化器比较等内容,非常全面.>>加入 ...

  9. 定点 浮点 神经网络 量化_神经网络模型量化论文小结

    神经网络模型量化论文小结 发布时间:2018-07-22 13:25, 浏览次数:278 现在"边缘计算"越来越重要,真正能落地的算法才是有竞争力的算法.随着卷积神经网络模型堆叠的 ...

  10. 神经网络模型量化论文小结

    现在"边缘计算"越来越重要,真正能落地的算法才是有竞争力的算法.随着卷积神经网络模型堆叠的层数越来越多,网络模型的权重参数数量也随之增长,专用硬件平台可以很好的解决计算与存储的双重 ...

最新文章

  1. php round函数输出不对_PHP常量
  2. ftp连接 java.net.ConnectException: Connection refused
  3. Bumblebee微服务网关之访问日志处理
  4. 谷歌gcp 远程计算机_引导性GCP:带有Google Cloud Pub / Sub的Spring Cloud Stream
  5. Typescript 学习笔记一:介绍、安装、编译
  6. idea 配置mysql逆向_idea逆向工程配置
  7. python pow函数用法_Python代码中pow()函数具有哪些功能呢?
  8. Spring JDBC 框架中, 绑定 SQL 参数的另一种选择:具名参数(named parameter)
  9. python微信爬虫
  10. matlab程序的m语言,M语言GMSK程序求教
  11. layui文件上传后台(带自定参数)
  12. uniapp实现滚动到底部加载更多数据
  13. 2022.2.20自制豆腐
  14. 比亚迪DiLink深体验:让科幻般的车生活都成为实现,智能网联集大成者张这样?...
  15. Python数据分析之Pandas库
  16. 关于消息推送服务的十问十答
  17. 项目>点餐系统 总结概述
  18. 2.1在 U-Boot 中添加自己的开发板
  19. 饼图自定义legend文字内容,以及饼图中间显示数量 ,中国地图制作
  20. C语言定义变量用什么字母,C语言中变量名有什么要求 C语言中,什么是变量和变量名?它们的区别是什么?...

热门文章

  1. ES6 Generator 函数
  2. 第17章 高级数据表示 17.7 二叉搜索树(第一部分ADT 和 接口)
  3. Ubuntu应用Wireshark找不到interface的解决办法
  4. NOD32 2.7、3.0最新升级ID 每天实时同步更新
  5. unittest框架(惨不忍睹低配版)
  6. sping加载bean都发生了些什么
  7. sts bug SpringJUnit4ClassRunner
  8. nodejs - 服务端管理 - PM2
  9. 元素“UpdateProgress”不是已知元素。原因可能是网站中存在编译错误
  10. c++构造函数、析构函数为什么不能取地址