首页 > 其他分享 >MLPClassifier 隐藏层不包括输入和输出

MLPClassifier 隐藏层不包括输入和输出

时间:2023-09-08 14:03:05浏览次数:34  
标签:function constant MLPClassifier default solver rate learning 隐藏 输入

多层感知机(MLP)原理简介

多层感知机(MLP,Multilayer Perceptron)也叫人工神经网络(ANN,Artificial Neural Network),除了输入输出层,它中间可以有多个隐层,最简单的MLP只含一个隐层,即三层的结构,如下图:

MLPClassifier 隐藏层不包括输入和输出_sed

 

从上图可以看到,多层感知机层与层之间是全连接的(全连接的意思就是:上一层的任何一个神经元与下一层的所有神经元都有连接)。多层感知机最底层是输入层,中间是隐藏层,最后是输出层。

 

输入层没什么好说,你输入什么就是什么,比如输入是一个n维向量,就有n个神经元。

隐藏层的神经元怎么得来?首先它与输入层是全连接的,假设输入层用向量X表示,则隐藏层的输出就是

f(W1X+b1),W1是权重(也叫连接系数),b1是偏置,函数f 可以是常用的sigmoid函数或者tanh函数:

 

MLPClassifier 隐藏层不包括输入和输出_机器学习_02

 

     

MLPClassifier 隐藏层不包括输入和输出_机器学习_03

 

 

最后就是输出层,输出层与隐藏层是什么关系?其实隐藏层到输出层可以看成是一个多类别的逻辑回归,也即softmax回归,所以输出层的输出就是softmax(W2X1+b2),X1表示隐藏层的输出f(W1X+b1)。

sklearn.neural_network.MLPClassifier

class sklearn.neural_network.MLPClassifier(hidden_layer_sizes=(100, ), activation=’relu’, solver=’adam’, alpha=0.0001, batch_size=’auto’, learning_rate=’constant’, learning_rate_init=0.001, power_t=0.5, max_iter=200, shuffle=True, random_state=None, tol=0.0001, verbose=False, warm_start=False, momentum=0.9, nesterovs_momentum=True, early_stopping=False, validation_fraction=0.1, beta_1=0.9, beta_2=0.999, epsilon=1e-08, n_iter_no_change=10)[source]

Multi-layer Perceptron classifier.

This model optimizes the log-loss function using LBFGS or stochastic gradient descent.

New in version 0.18.

Parameters:

hidden_layer_sizes : tuple, length = n_layers - 2, default (100,)
The ith element represents the number of neurons in the ith hidden layer.
activation : {‘identity’, ‘logistic’, ‘tanh’, ‘relu’}, default ‘relu’
Activation function for the hidden layer.
• ‘identity’, no-op activation, useful to implement linear bottleneck, returns f(x) = x
• ‘logistic’, the logistic sigmoid function, returns f(x) = 1 / (1 + exp(-x)).
• ‘tanh’, the hyperbolic tan function, returns f(x) = tanh(x).
• ‘relu’, the rectified linear unit function, returns f(x) = max(0, x)
solver : {‘lbfgs’, ‘sgd’, ‘adam’}, default ‘adam’
The solver for weight optimization.
• ‘lbfgs’ is an optimizer in the family of quasi-Newton methods.
• ‘sgd’ refers to stochastic gradient descent.
• ‘adam’ refers to a stochastic gradient-based optimizer proposed by Kingma, Diederik, and Jimmy Ba
Note: The default solver ‘adam’ works pretty well on relatively large datasets (with thousands of training samples or more) in terms of both training time and validation score. For small datasets, however, ‘lbfgs’ can converge faster and perform better.
alpha : float, optional, default 0.0001
L2 penalty (regularization term) parameter.
batch_size : int, optional, default ‘auto’
Size of minibatches for stochastic optimizers. If the solver is ‘lbfgs’, the classifier will not use minibatch. When set to “auto”, batch_size=min(200, n_samples)
learning_rate : {‘constant’, ‘invscaling’, ‘adaptive’}, default ‘constant’
Learning rate schedule for weight updates.
• ‘constant’ is a constant learning rate given by ‘learning_rate_init’.
• ‘invscaling’ gradually decreases the learning rate learning_rate_ at each time step ‘t’ using an inverse scaling exponent of ‘power_t’. effective_learning_rate = learning_rate_init / pow(t, power_t)
• ‘adaptive’ keeps the learning rate constant to ‘learning_rate_init’ as long as training loss keeps decreasing. Each time two consecutive epochs fail to decrease training loss by at least tol, or fail to increase validation score by at least tol if ‘early_stopping’ is on, the current learning rate is divided by 5.
Only used when solver='sgd'.
learning_rate_init : double, optional, default 0.001
The initial learning rate used. It controls the step-size in updating the weights. Only used when solver=’sgd’ or ‘adam’.
power_t : double, optional, default 0.5
The exponent for inverse scaling learning rate. It is used in updating effective learning rate when the learning_rate is set to ‘invscaling’. Only used when solver=’sgd’.

概述

MLPClassifier 隐藏层不包括输入和输出_激活函数_04


神经网络模型

所谓神经网络就是将许多个单一“神经元”联结在一起,这样,一个“神经元”的输出就可以是另一个“神经元”的输入。例如,下图就是一个简单的神经网络:

MLPClassifier 隐藏层不包括输入和输出_神经网络_05

MLPClassifier 隐藏层不包括输入和输出_python_06


MLPClassifier 隐藏层不包括输入和输出_神经网络_07

MLPClassifier 隐藏层不包括输入和输出_sed_08

中英文对照

neural networks 神经网络

activation function 激活函数

hyperbolic tangent 双曲正切函数

bias units 偏置项

activation 激活值

forward propagation 前向传播

feedforward neural network 前馈神经网络(参照Mitchell的《机器学习》的翻译)

标签:function,constant,MLPClassifier,default,solver,rate,learning,隐藏,输入
From: https://blog.51cto.com/u_11908275/7409488

相关文章

  • Vue可输入的下拉框
    原文链接:https://blog.csdn.net/m0_72189030/article/details/130881295<template><el-selectv-model="value"placeholder="请选择"clearable:style="{width:'100%'}"filterableallow-create:fi......
  • Excel 当单元格内容为空时自动隐藏本行
    宏代码如下:PrivateSubWorksheet_Change(ByValTargetAsRange)IfTarget.Column=3ThenIfTarget.Value=""ThenTarget.EntireRow.Hidden=TrueEndIfEndIfEndSub首先鼠标右击该工作表名称标签,点击“查看代码”命令,随即自动进入到VBA代码编辑窗口,然后我们将上面的一段......
  • pageoffice 6版本隐藏office工具栏和自定义按钮,并修改标题栏内容
    在实际项目集成调用PageOffice的过程中:(1)有时需要把Office的工具栏隐藏,比如只读模式打开文件的时候,Office工具栏上的按钮几乎都是灰掉的,此时显示Office工具栏没有任何意义,并且浪费了宝贵的界面空间。实现此功能只需在OnPageOfficeCtrlInit事件中调用js设置PageOffice控件的Office......
  • css实现 h5滑动时隐藏滚动条
    .menus{margin:10px0;margin-left:18px;display:flex;flex-wrap:nowrap;overflow-x:auto;}.menus::-webkit-scrollbar{display:none;width:0!important;height:0!important;-webkit-appearance:none;background:tra......
  • 输入输出(io)控制方式
        ......
  • 在Canvas上进行文本输入及其它html元素操作
    问题使用canvas绘制了一个表格,想要在上面进行编辑操作,但canvas并不支持修改操作思路通过给html元素设置绝对定位,遮盖canvas上的指定位置,所有编辑操作都在元素上进行,也可以将元素的值绘制到canvas上,示例demo如下:点击查看代码<!DOCTYPEHTML><html><style></style><bodys......
  • 小红书旅行攻略:发现隐藏景点的窍门
    小红书旅行攻略:发现隐藏景点的窍门嗨,亲爱的小红书探险家们!欢迎来到小紫的专属旅行攻略,今天我将分享一些独特的窍门,帮助你们在旅途中发现那些令人叹为观止的隐藏景点。快跟着我一起展开这段奇妙的旅程吧!1.社区推荐-揭秘当地人心头好......
  • 如何隐藏mui TextField标签?
    要隐藏MUI(Material-UI)的TextField标签,您可以使用CSS来修改其样式。以下是一种可能的方法:为TextField添加一个自定义的CSS类名或ID,以便在CSS中进行样式修改。例如,假设您给TextField添加了custom-textfield类名:<TextFieldclassName="custom-textfield"label="L......
  • Python开发实例(十二)天气预报应用:通过API获取天气数据,让用户输入城市并显示天气情况
    在这个实例中,我们将创建一个天气预报应用,使用Python的requests库来获取天气数据,并让用户输入城市名来显示该城市的天气情况。首先,你需要申请一个天气数据的API密钥。在这个示例中,我们将使用OpenWeatherMap提供的API,你可以在https://openweathermap.org/上注册并获取免费的API密钥......
  • 函数的调用以及显示内容的隐藏
    写程序的终极原则:高内聚,低耦合--->highcohesionlowcoupling设计函数最为重要的原则:单一职责原则(一个函数只做好一件事情)--->高度内聚模块调取隐藏判定:ifname=='main':#__name__是一个隐藏变量,它代表了当前模块(文件)的名字#如果直接通过Python解释器运行example16.p......