Skip to main content

Command Palette

Search for a command to run...

How do models learn?

Updated
3 min readView as Markdown
How do models learn?

In general, machine learning models learn by adjusting their parameters to minimize a loss function, which is a measure of how well the model is performing on a given task. The process of adjusting the parameters is done by an optimization algorithm, which iteratively updates the parameter values based on the gradients of the loss function concerning the parameters.

During the training process, the model is fed with input data and corresponding output labels, and it tries to make predictions based on that data. The predictions are then compared with the actual output labels, and the difference between them is used to update the model's parameters. This process is repeated many times, typically over a large dataset, until the model's performance on the task is satisfactory.

Different machine learning algorithms use different techniques to adjust their parameters, and some are better suited to certain types of problems than others. Some common techniques include gradient descent, stochastic gradient descent, and backpropagation.

  • Loss

    • A measure of how close our model predictions are from their true values.

    • We could assess the total loss within our system by taking an average of this loss across all houses in the dataset.

  • Regression

    • In machine learning and statistics, regression is a method for modelling the relationship between a dependent variable (often denoted as y) and one or more independent variables (often denoted as x).

    • The goal of regression is to find the best fit between the dependent variable and the independent variable(s), by estimating the coefficients that describe the relationship between them.

    • Regression is used in various fields, including finance, economics, psychology, and engineering, for making predictions, forecasting, and identifying patterns in data.

  • Fully connected layer

    • Every input node is connected to every node in another layer

https://deeplearningmath.org/general-fully-connected-neural-networks.html

Evaluating Data

  • Accuracy = number of correct predictions / total predictions

  • true negatives; predicted as not a target correctly

  • false negatives; predicted as not a target incorrectly

  • Instead of just using accuracy, we should evaluate our model using precision and recall

    • recall of zero; no positive results were returned

    • Precision = True Positives / (True Positives + False Positives)

    • Recall = True Positives / (True Positives + False Negatives)

Activation Function

  • If we wish our neural networks to learn a truly complex, then we must introduce an element of nonlinearity into our model through activation functions

  • Nonlinearity in a neural network is important because it allows the network to model complex relationships between inputs and outputs.

  • Without nonlinearity, a neural network would be limited to only linear transformations of its input, which can severely limit its expressive power.

  • Nonlinear activation functions like the sigmoid, ReLU, and tanh allow neural networks to learn and model more complex patterns and relationships in the data, which can ultimately lead to better performance on tasks like classification and regression.

Performing gradient descent on neural networks

  1. Perform a forward pass using your data, calculating the total loss of the network.

  2. Using backpropagation, calculate the gradients of each parameter concerning loss at each node in the network.

  3. Update the value of these parameters, moving toward the direction where loss is minimized.

  4. Repeat until convergence.

Reference

  • Link: Hands-On Natural Language Processing with PyTorch 1.x: Build smart, AI-driven linguistic applications using deep learning and NLP techniques: Dop, Thomas: 9781789802740: Amazon.com: Books (amazon.com)

More from this blog

Learning Machine Learning

7 posts