Table of Contents
LP norm
Dropout
The difference between normalization and standardization:
Why standardization and normalization?
Home Technology peripherals AI Machine learning essentials: How to prevent overfitting?

Machine learning essentials: How to prevent overfitting?

Apr 13, 2023 pm 06:37 PM
machine learning algorithm deep learning

In fact, the essence of regularization is very simple. It is a means or operation that imposes a priori restrictions or constraints on a certain problem to achieve a specific purpose. The purpose of using regularization in an algorithm is to prevent the model from overfitting. When it comes to regularization, many students may immediately think of the commonly used L1 norm and L2 norm. Before summarizing, let's first take a look at what the LP norm is?

LP norm

The norm can be simply understood as used to represent the distance in the vector space, and the definition of distance is very abstract. It can be called as long as it satisfies non-negative, reflexive, and triangle inequalities. It's distance.

LP norm is not a norm, but a set of norms, which is defined as follows:

Machine learning essentials: How to prevent overfitting?

##The range of p is [1,∞). p is not defined as a norm in the range of (0,1) because it violates the triangle inequality.

According to the change of pp, the norm also has different changes. Borrowing a classic change diagram of P norm as follows:

Machine learning essentials: How to prevent overfitting?

The above picture represents It shows the change of the unit ball when p changes from 0 to positive infinity. The unit ball defined under the P norm is a convex set, but when 0

Then the question comes, what is the L0 norm? The L0 norm represents the number of non-zero elements in the vector, expressed as follows:

Machine learning essentials: How to prevent overfitting?

We can find the least optimal sparse features by minimizing the L0 norm. item. But unfortunately, the optimization problem of L0 norm is an NP hard problem (L0 norm is also non-convex). Therefore, in practical applications, we often perform convex relaxation of L0. It is theoretically proven that the L1 norm is the optimal convex approximation of the L0 norm, so the L1 norm is usually used instead of directly optimizing the L0 norm.

L1 norm

According to the definition of LP norm we can easily get the mathematical form of L1 norm:

Machine learning essentials: How to prevent overfitting?

Pass As can be seen from the above formula, the L1 norm is the sum of the absolute values ​​of each element of the vector, also known as the "sparse regularization operator" (Lasso regularization). So the question is, why do we want sparsification? There are many benefits to sparsification, the two most direct ones are:

    Feature selection
  • Interpretability
L2 norm

The L2 norm is the most familiar. It is the Euclidean distance. The formula is as follows:

Machine learning essentials: How to prevent overfitting?

The L2 norm has many names. Some people call its regression "ridge regression." "(Ridge Regression), some people also call it "Weight Decay". Using the L2 norm as a regularization term can obtain a dense solution, that is, the parameter ww corresponding to each feature is very small, close to 0 but not 0; in addition, the L2 norm as a regularization term can prevent the model from catering to the training set. Too much complexity leads to overfitting, thereby improving the generalization ability of the model.

The difference between L1 norm and L2 norm

Introduce a classic diagram of PRML to illustrate the difference between L1 and L2 norm, as shown in the following figure:

Machine learning essentials: How to prevent overfitting?

Machine learning essentials: How to prevent overfitting?

As shown in the figure above, the blue circle represents the possible solution range of the problem, and the orange circle represents the possible solution range of the regular term. The entire objective function (regular term of the original problem) has a solution if and only if the two solution ranges are tangent. It can be easily seen from the above figure that since the L2 norm solution range is a circle, the tangent point is most likely not on the coordinate axis, and since the L1 norm is a rhombus (the vertex is convex), its tangent point The tangent point is more likely to be on the coordinate axis, and the point on the coordinate axis has a characteristic that only one coordinate component is non-zero, and the other coordinate components are zero, that is, it is sparse. Therefore, there is the following conclusion: L1 norm can lead to sparse solutions, and L2 norm can lead to dense solutions.

From a Bayesian prior perspective, when training a model, it is not enough to rely solely on the current training data set. In order to achieve better generalization capabilities, it is often necessary to add prior terms, and regular terms It is equivalent to adding a priori.

  • The L1 norm is equivalent to adding a Laplacean prior;
  • The L2 norm is equivalent to adding a Gaussian prior.

As shown in the figure below:

Machine learning essentials: How to prevent overfitting?

Dropout

Dropout is a regularization method often used in deep learning. Its approach can be simply understood as discarding some neurons with probability p during the training process of DNNs, that is, the output of the discarded neurons is 0. Dropout can be instantiated as shown in the figure below:

Machine learning essentials: How to prevent overfitting?

## We can intuitively understand the regularization effect of Dropout from two aspects:

    The operation of randomly losing neurons during each round of Dropout training is equivalent to averaging multiple DNNs, so it has the effect of voting when used for prediction.
  • Reduce the complex co-adaptation between neurons. When the hidden layer neurons are randomly deleted, the fully connected network becomes sparse to a certain extent, thus effectively reducing the synergistic effects of different features. In other words, some features may rely on the joint action of hidden nodes with fixed relationships, and through Dropout, it effectively organizes the situation where some features are effective only in the presence of other features, increasing the robustness of the neural network. Great sex.
Batch Normalization

Batch Normalization is strictly a normalization method, mainly used to accelerate the convergence of the network, but it also has a certain degree of regularization effect. .

Here is a reference to the explanation of covariate shift in Dr. Wei Xiushen’s Zhihu answer.

Note: The following content is quoted from Dr. Wei Xiushen’s Zhihu answer. Everyone knows that a classic assumption in statistical machine learning is “the data distribution of source space (source domain) and target space (target domain)” (distribution) is consistent”. If they are inconsistent, then new machine learning problems arise, such as transfer learning/domain adaptation, etc. Covariate shift is a branch problem under the assumption of inconsistent distribution. It means that the conditional probabilities of the source space and the target space are consistent, but their marginal probabilities are different. If you think about it carefully, you will find that indeed, for the output of each layer of the neural network, because they have undergone intra-layer operations, their distribution is obviously different from the distribution of the input signals corresponding to each layer, and the difference will increase as the depth of the network increases. are large, but the sample labels they can "indicate" remain unchanged, which meets the definition of covariate shift.

The basic idea of ​​BN is actually quite intuitive, because the activation input value of the neural network before nonlinear transformation (X=WU B, U is the input) as the depth of the network deepens, its distribution gradually shifts or Change (ie the above-mentioned covariate shift). The reason why training converges slowly is generally because the overall distribution gradually approaches the upper and lower limits of the value range of the nonlinear function (for the Sigmoid function, it means that the activation input value X=WU B is a large negative or positive value) , so this causes the gradient of the low-level neural network to disappear during backpropagation, which is the essential reason why the convergence of deep neural networks in training becomes slower and slower. BN uses a certain standardization method to force the distribution of the input value of any neuron in each layer of the neural network back to the standard normal distribution with a mean of 0 and a variance of 1, to avoid the gradient dispersion problem caused by the activation function. So rather than saying that the role of BN is to alleviate covariate shift, it is better to say that BN can alleviate the gradient dispersion problem.

Normalization, Standardization & Regularization

We have mentioned regularization before, here we briefly mention normalization and standardization. Normalization: The goal of normalization is to find a certain mapping relationship to map the original data to the [a, b] interval. Generally, a and b will take combinations of [−1,1], [0,1]. There are generally two application scenarios:

    Convert the number into a decimal between (0, 1)
  • Convert the dimensional number into a dimensionless number
Commonly used min-max normalization:

Machine learning essentials: How to prevent overfitting?

Standardization (Standardization): Use the theorem of large numbers to transform the data into a standard normal distribution. The standardization formula is:

Machine learning essentials: How to prevent overfitting?

The difference between normalization and standardization:

We can explain it simply like this: normalized scaling is "flattened" to the interval (determined only by extreme values), while standardized scaling is It is more "elastic" and "dynamic" and has a lot to do with the distribution of the overall sample. Note:

  • Normalization: Scaling is only related to the difference between the maximum and minimum values.
  • Standardization: Scaling is related to each point and is reflected by variance. Contrast this with normalization, in which all data points contribute (through the mean and standard deviation).

Why standardization and normalization?

  • Improve model accuracy: After normalization, the features between different dimensions are numerically comparable, which can greatly improve the accuracy of the classifier.
  • Accelerate model convergence: After standardization, the optimization process of the optimal solution will obviously become smoother, making it easier to correctly converge to the optimal solution. As shown below:

Machine learning essentials: How to prevent overfitting?

Machine learning essentials: How to prevent overfitting?

The above is the detailed content of Machine learning essentials: How to prevent overfitting?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

This article will take you to understand SHAP: model explanation for machine learning This article will take you to understand SHAP: model explanation for machine learning Jun 01, 2024 am 10:58 AM

In the fields of machine learning and data science, model interpretability has always been a focus of researchers and practitioners. With the widespread application of complex models such as deep learning and ensemble methods, understanding the model's decision-making process has become particularly important. Explainable AI|XAI helps build trust and confidence in machine learning models by increasing the transparency of the model. Improving model transparency can be achieved through methods such as the widespread use of multiple complex models, as well as the decision-making processes used to explain the models. These methods include feature importance analysis, model prediction interval estimation, local interpretability algorithms, etc. Feature importance analysis can explain the decision-making process of a model by evaluating the degree of influence of the model on the input features. Model prediction interval estimate

Beyond ORB-SLAM3! SL-SLAM: Low light, severe jitter and weak texture scenes are all handled Beyond ORB-SLAM3! SL-SLAM: Low light, severe jitter and weak texture scenes are all handled May 30, 2024 am 09:35 AM

Written previously, today we discuss how deep learning technology can improve the performance of vision-based SLAM (simultaneous localization and mapping) in complex environments. By combining deep feature extraction and depth matching methods, here we introduce a versatile hybrid visual SLAM system designed to improve adaptation in challenging scenarios such as low-light conditions, dynamic lighting, weakly textured areas, and severe jitter. sex. Our system supports multiple modes, including extended monocular, stereo, monocular-inertial, and stereo-inertial configurations. In addition, it also analyzes how to combine visual SLAM with deep learning methods to inspire other research. Through extensive experiments on public datasets and self-sampled data, we demonstrate the superiority of SL-SLAM in terms of positioning accuracy and tracking robustness.

Implementing Machine Learning Algorithms in C++: Common Challenges and Solutions Implementing Machine Learning Algorithms in C++: Common Challenges and Solutions Jun 03, 2024 pm 01:25 PM

Common challenges faced by machine learning algorithms in C++ include memory management, multi-threading, performance optimization, and maintainability. Solutions include using smart pointers, modern threading libraries, SIMD instructions and third-party libraries, as well as following coding style guidelines and using automation tools. Practical cases show how to use the Eigen library to implement linear regression algorithms, effectively manage memory and use high-performance matrix operations.

Explainable AI: Explaining complex AI/ML models Explainable AI: Explaining complex AI/ML models Jun 03, 2024 pm 10:08 PM

Translator | Reviewed by Li Rui | Chonglou Artificial intelligence (AI) and machine learning (ML) models are becoming increasingly complex today, and the output produced by these models is a black box – unable to be explained to stakeholders. Explainable AI (XAI) aims to solve this problem by enabling stakeholders to understand how these models work, ensuring they understand how these models actually make decisions, and ensuring transparency in AI systems, Trust and accountability to address this issue. This article explores various explainable artificial intelligence (XAI) techniques to illustrate their underlying principles. Several reasons why explainable AI is crucial Trust and transparency: For AI systems to be widely accepted and trusted, users need to understand how decisions are made

Five schools of machine learning you don't know about Five schools of machine learning you don't know about Jun 05, 2024 pm 08:51 PM

Machine learning is an important branch of artificial intelligence that gives computers the ability to learn from data and improve their capabilities without being explicitly programmed. Machine learning has a wide range of applications in various fields, from image recognition and natural language processing to recommendation systems and fraud detection, and it is changing the way we live. There are many different methods and theories in the field of machine learning, among which the five most influential methods are called the "Five Schools of Machine Learning". The five major schools are the symbolic school, the connectionist school, the evolutionary school, the Bayesian school and the analogy school. 1. Symbolism, also known as symbolism, emphasizes the use of symbols for logical reasoning and expression of knowledge. This school of thought believes that learning is a process of reverse deduction, through existing

Improved detection algorithm: for target detection in high-resolution optical remote sensing images Improved detection algorithm: for target detection in high-resolution optical remote sensing images Jun 06, 2024 pm 12:33 PM

01 Outlook Summary Currently, it is difficult to achieve an appropriate balance between detection efficiency and detection results. We have developed an enhanced YOLOv5 algorithm for target detection in high-resolution optical remote sensing images, using multi-layer feature pyramids, multi-detection head strategies and hybrid attention modules to improve the effect of the target detection network in optical remote sensing images. According to the SIMD data set, the mAP of the new algorithm is 2.2% better than YOLOv5 and 8.48% better than YOLOX, achieving a better balance between detection results and speed. 02 Background & Motivation With the rapid development of remote sensing technology, high-resolution optical remote sensing images have been used to describe many objects on the earth’s surface, including aircraft, cars, buildings, etc. Object detection in the interpretation of remote sensing images

Is Flash Attention stable? Meta and Harvard found that their model weight deviations fluctuated by orders of magnitude Is Flash Attention stable? Meta and Harvard found that their model weight deviations fluctuated by orders of magnitude May 30, 2024 pm 01:24 PM

MetaFAIR teamed up with Harvard to provide a new research framework for optimizing the data bias generated when large-scale machine learning is performed. It is known that the training of large language models often takes months and uses hundreds or even thousands of GPUs. Taking the LLaMA270B model as an example, its training requires a total of 1,720,320 GPU hours. Training large models presents unique systemic challenges due to the scale and complexity of these workloads. Recently, many institutions have reported instability in the training process when training SOTA generative AI models. They usually appear in the form of loss spikes. For example, Google's PaLM model experienced up to 20 loss spikes during the training process. Numerical bias is the root cause of this training inaccuracy,

AlphaFold 3 is launched, comprehensively predicting the interactions and structures of proteins and all living molecules, with far greater accuracy than ever before AlphaFold 3 is launched, comprehensively predicting the interactions and structures of proteins and all living molecules, with far greater accuracy than ever before Jul 16, 2024 am 12:08 AM

Editor | Radish Skin Since the release of the powerful AlphaFold2 in 2021, scientists have been using protein structure prediction models to map various protein structures within cells, discover drugs, and draw a "cosmic map" of every known protein interaction. . Just now, Google DeepMind released the AlphaFold3 model, which can perform joint structure predictions for complexes including proteins, nucleic acids, small molecules, ions and modified residues. The accuracy of AlphaFold3 has been significantly improved compared to many dedicated tools in the past (protein-ligand interaction, protein-nucleic acid interaction, antibody-antigen prediction). This shows that within a single unified deep learning framework, it is possible to achieve

See all articles