Archive for the ‘Machine Learning’ Category

Top 10 Most Powerful AI Tools. A Deep Dive into the Top 10 AI Tools | by Token Tales | Jan, 2024 – Medium

A Deep Dive into the Top 10 AI Tools Transforming Industries.

Artificial Intelligence (AI) has evolved rapidly over the past few years, transforming the way businesses operate and revolutionizing various industries. From machine learning algorithms to natural language processing, AI tools have become essential for automating tasks, gaining insights from data, and enhancing decision-making processes. In this article, we will explore the top 10 most powerful AI tools that are making a significant impact in the field.

In conclusion, the field of AI is advancing at an unprecedented pace, and these powerful tools are at the forefront of this technological revolution. From machine learning frameworks to cognitive computing platforms, these tools empower developers, data scientists, and businesses to harness the potential of AI and drive innovation across various domains. As AI continues to evolve, staying informed about the latest tools and technologies is crucial for those looking to leverage the full potential of artificial intelligence.

Read more here:
Top 10 Most Powerful AI Tools. A Deep Dive into the Top 10 AI Tools | by Token Tales | Jan, 2024 - Medium

The Skys the Limit – Scotsman Guide News

Artificial intelligence (AI) and machine learning represent powerful tools that harness the capabilities of computers to analyze vast volumes of data, make informed decisions and continually learn from their experiences. Their applications offer demonstrable solutions to irrefutable challenges.

These tools, as they continue to advance, are projected to drive a 7% (or $7 trillion) increase in global gross domestic product and boost productivity growth by 1.5 percentage points over a 10-year period, according to Goldman Sachs. Even now, AI and machine learning are revolutionizing the mortgage sector by streamlining processes, improving risk assessment and reshaping the lending landscape.

Welcome to the future of mortgage origination a future where AI and machine learning spearhead progress.

These technologies are making processes more efficient, fueling an era of increased accuracy, reduced risk, and better experiences for lenders and borrowers. Allied Market Research reported that the global mortgage market, which generated nearly $11.5 trillion in 2021, is projected to reach $27.5 trillion by 2031, with a compound annual growth rate of 9.5% from 2022 to 2031. A main driver for this projected growth is the increased investment in software that speeds up the mortgage application process.

Navigating the complexities of this technological evolution will enable the mortgage industry to examine some of its existing challenges while ensuring that the benefits of AI are realized without compromising ethics or fairness in lending practices. Welcome to the future of mortgage origination a future where AI and machine learning spearhead progress.

The loan origination process has historically been a labor-intensive and time-consuming effort. Mortgage originators have had to scrutinize mountains of paperwork, verify financial documents and manually evaluate creditworthiness a lengthy process that could take several weeks. The arrival of AI and machine learning, however, has brought about a seismic shift in how this process is executed, offering a host of benefits.

One of the most notable advantages of AI and machine learning in mortgage origination is the automation of repetitive tasks. Intelligent algorithms can now handle tasks such as data entry, document verification and information extraction that once required substantial human involvement. This cuts the workload for mortgage originators and reduces the chances of errors that accompany manual data entry.

The loan origination process also becomes considerably more efficient with AI and machine learning. Algorithms can analyze massive quantities of data in a fraction of the time it would take a human, facilitating faster loan approval times. Borrowers no longer have to endure long wait times for decisions on their applications, resulting in a more positive experience.

Ethical AI development is imperative to avoid bias, discrimination and unfair lending practices.

In addition, AI and machine learning support a more borrower- focused approach. These technologies enable lenders to provide personalized services and faster response times. A borrower can receive real-time updates on the status of their application, the result of a more transparent and less stressful process.

AI and machine learning algorithms can analyze a multitude of data points far beyond what traditional approaches could accomplish. These technologies consider financial data and factors like borrower behavior and online digital history. This broad analysis results in more informed lending decisions, increasing the probability of approved loans that manual processes may have overlooked.

The adoption of AI and machine learning in mortgage origination can lead to substantial cost savings. Lenders can allocate resources more efficiently and reduce the need for extensive manual labor. These savings can be passed to borrowers through lower fees and interest rates.

Risk assessment is a pivotal stage in mortgage origination. Traditionally, lenders relied heavily on financial data such as credit scores and income verification. Today, AI and machine learning integration unlocks a wealth of digital data sources, offering a complete understanding of borrower risk.

AI and machine learning are expanding risk assessment capabilities by examining a borrowers online digital history, which comprises social media activity, mobile device usage, payment systems and online transactions. This provides insights into an applicants financial behaviors and lifestyle choices that were not previously visible.

AI algorithms identify elusive patterns and anomalies in a borrowers digital history, enabling highly informed lending decisions. These algorithms can recognize responsible financial behavior and detect potential issues like erratic income sources or unusual spending habits, considerably minimizing a lenders default risk.

Additionally, AI acts as a vigilant protector, combating fraud by continually monitoring online activities and transactions. AI quickly detects anomalies and suspicious patterns, safeguarding both lenders and borrowers.

AIs objectivity and consistency decrease the potential for human error, generating more reliable risk assessments. Customized risk profiles tailored to an individuals circumstances offer a more equitable lending environment while faster decisionmaking benefits borrowers.

Mortgage originators can modernize operations and improve lending practices by implementing AI and machine learning solutions. These advanced technologies can contribute to a more equitable and efficient lending ecosystem by reducing costs, eliminating errors and mitigating bias. Responsible AI adoption supports principles of fairness and accuracy in the mortgage industry while producing multifaceted rewards.

Traditional mortgage origination processes are resource-intensive, requiring ample human labor to perform tasks such as data entry and document verification. AI and machine learning automation markedly reduce the need for manual involvement. This improved operational efficiency gradually lowers overhead costs, aiding originators in allocating resources more effectively.

Manual processes are susceptible to human error and in mortgage origination, errors can be costly. AI and machine learning excel in consistency and accuracy, eliminating the likelihood of errors in tasks that can be automated. This results in a more dependable origination process, benefiting lenders and borrowers by preventing costly mistakes.

Bias in lending, such as digital redlining, is a challenge associated with these technologies. AI and machine learning systems can be designed for transparency, auditability and continuous fairness monitoring. Ethical AI development practices and diverse, representative datasets ensure that lending decisions are based on objective criteria rather than the perpetuation of historic biases. Systematic audits and oversight are key to maintaining fairness and compliance.

The adoption of AI and machine learning in mortgage origination produces transformative benefits, but unique challenges call for prudent navigation. Because AI and machine learning greatly depend on borrower data for risk assessment and automation, ensuring the privacy and security of data is paramount.

Lenders must employ robust data encryption, secure storage practices and strict adherence to data protection regulations. Building trust through transparent handling practices is critical to assure borrowers of their datas safety.

Ethical AI development is imperative to avoid bias, discrimination and unfair lending practices. Using diverse and representative datasets for training, routinely auditing algorithms for fairness, and maintaining transparency in lending decisions are critical steps in establishing ethical AI practices and ending digital redlining.

The highly regulated mortgage industry demands strict adherence to rules and standards. AI and machine learning integrations must align with these regulations, requiring close collaboration with legal experts to certify compliance, particularly when AI-driven decisions have financial implications for borrowers.

Maintaining transparency in lending decisions is of great importance since AI and machine learning algorithms operate in ways that can be difficult to understand or interpret. To build trust, borrowers must have explanations for how these technologies are used in lending processes.

While automation is a key advantage, human oversight remains essential. Striking the right balance between automation and human intervention affirms that AI-driven decisions support organizational goals and consider complex cases or exceptions.

AI and machine learning technologies evolve rapidly. Keeping pace with advancements and adapting systems accordingly are ongoing challenges. Investments in ongoing training and having a keen eye for evolving best practices are vital to remain competitive and compliant.

Integrating AI and machine learning into mortgage origination marks a profound shift in the lending landscape that offers promise, opportunity and challenges. AI and machine learning will modernize the origination process by providing operational efficiencies, faster approval times and better client experiences.

Borrowers benefit from faster decisions while lenders enjoy cost savings and enhanced accuracy. By implementing these technologies responsibly and addressing challenges diligently, mortgage originators can lead the industry toward a more competitive, compliant and borrower-centric future.

Kuldeep Saxena is a project manager who oversees mortgage and lending projects for Chetu, a global custom software solutions development and support services provider. Saxena, who has been working for more than 10 years at Chetu, has a masters degree in computer applications and more than 15 years of experience in IT software.

View all posts

Read more:
The Skys the Limit - Scotsman Guide News

Weekly AiThority Roundup: Biggest Machine Learning, Robotic And Automation Updates – AiThority

This is your AI Weekly Roundup. We are covering the top updates from around the world. The updates will feature state-of-the-art capabilities inartificial intelligence (AI),Machine Learning, Robotic Process Automation, Fintech, and human-system interactions. We cover the role of AI Daily Roundup and its application in various industries and daily lives.

Lenovo, a global tech powerhouse, takes center stage in 2023 with a cascade of exciting news stories that underscore its continued influence in the ever-evolving world of technology. Embarking on the journey of a new year, Lenovo sets the tone with a series of top-tier developments, positioning itself at the forefront of innovation and progress in 2023.

DataStax, the company that powersgenerative AIapplications with real-time, scalable data announced the launch ofSwiftieGPT, an AI-powered chatbot that knows everything about Taylor Swift. Timed with the award-winning artists 34th birthday, SwiftieGPT provides Taylor Swift fans, better known as Swifties, with access to any and all publicly available data via a conversational bot that knows Taylor all too well.

VOZIQ AIrecently concluded the executive review meeting withDave Bolen, Chief Operating Officer at AMP Smart, where VOZIQ AIs Chief Data Scientist, Dr.Vasudeva Akula, rolled out a 365-day strategic roadmap for achieving$5 millionto$10 millionCLV increase through proactivecustomer experiencemanagement, proactive renewals, and loyalty management.

An unprecedented gathering of AI pioneers, experts, and fans, the Global AI Conclave 2023 was co-hosted by CNBC-TV18 and Moneycontrol. On December 16, the JW Mariott in Bengaluru hosted the conclave, which had 15 or more sessions moderated by prominent figures in artificial intelligence (AI) from India and throughout the world. So far, this is what has transpired throughout the event.

Meeami Technologiesa pioneer and leader inAudio AI,Noise Cancellation, Speaker ID and Spatial Audio, announced the availability of its AI based, and low footprint background noise suppression embedded solutions for the Cadence Tensilica HiFi DSP family.

[To share your insights with us, please write tosghosh@martechseries.com]

Originally posted here:
Weekly AiThority Roundup: Biggest Machine Learning, Robotic And Automation Updates - AiThority

Unlocking the Power of Python: Your Guide to Machine Learning Magic – Medium

Hello there, curious minds!

Ever wondered about the magic behind machine learning and how Python plays a key role in it? Well, buckle up because were about to take a friendly stroll through the fascinating world of Python and its dance with machine learning.

1. Python and Machine Learning: A Match Made in Tech Heaven

Imagine Python as the wizards wand in the world of tech. Its versatile, powerful, and, most importantly, friendly to beginners. Regarding machine learning, Python is the go-to language that transforms complex algorithms into readable lines of code.

2. Dive into the Python Ocean with Libraries and Packages

Ever heard of scikit-learn? Its like the superhero sidekick of Python in the machine learning realm. Well explore how this and other libraries make life easier by providing pre-built tools for various machine-learning tasks.

3. Sebastian Raschkas Book Your Friendly Guide to Python Machine Learning

Meet Sebastian Raschka, the Gandalf of Python Machine Learning. His book is like a treasure map for beginners, guiding you through the basics and unlocking the secrets of complex concepts. Spoiler alert: its not as intimidating as it sounds!

4. Python Machine Learning Models: Building Blocks of the Future

Well break down the jargon and explore real-world projects that showcase Pythons prowess in creating machine-learning models. Trust me; you dont need a rocket science PhD to understand this.

5. Python Tools and Frameworks: Your Tech Arsenal

Ever wondered what tools and frameworks make Python even more magical? Weve covered you with a sneak peek into the toolbox that turns you into a machine-learning wizard.

6. Python Machine Learning Algorithms: A Cheat Sheet for the Brain

Algorithms dont have to be the bad guys in your tech adventure. Well provide a cheat sheet that quickly turns complex algorithms into bite-sized pieces you can digest.

7. Python in Action: Real-world Applications and Success Stories

Pythons machine-learning applications are everywhere, from predicting the weather to helping doctors diagnose diseases. Well chat about some cool real-world examples that might surprise you.

8. Machine Learning Career 101: How Python Opens Doors

Thinking about a career in machine learning? Well spill the beans on the job market, salary insights, and essential skills. Spoiler alert: Python might be your golden ticket.

9. Deep Learning with Python: Going Beyond the Basics

Get ready to dive deeper into the Python ocean with deep learning. It sounds complex, but well break it down into simple terms, and you might find it as exciting as a superhero movie.

10. Python Machine Learning for Beginners: A Beginner-Friendly Guide

Not a tech whiz? No worries! Well hold your hand and guide you through the basics of Python machine learning. By the end of this section, you might call yourself a Python guru.

11. Python Machine Learning Projects: Lets Get Our Hands Dirty

Enough theory; its time for action! Well explore some GitHub projects and even guide you through creating a simple Python machine-learning project. Spoiler alert: Its going to be fun!

12. Wrapping it Up: Python, Machine Learning, and You

As we end our journey, youll realize that Python and machine learning arent reserved for tech geniuses. Its a world open to everyone, waiting for you to explore and create your tech magic.

So, are you ready to embark on this Python and machine-learning adventure? Grab your virtual backpack, and lets get started!

Affiliate Disclaimer:

This article may contain affiliate links, which means that if you click on one of the product links, I may receive a small commission.

More here:
Unlocking the Power of Python: Your Guide to Machine Learning Magic - Medium

Finding Optimal Learning Rates. The Learning Rate Range Test | by Francesco Franco | Jan, 2024 – Medium

The Learning Rate Range Test

Learning Rates are important when configuring a neural network. But choosing one is not easy, as there is no single best learning rate due to its dependency on your dataset.

Now, how to choose one? And should it be a fixed one or should I use learning rate decay? If I know how Ill choose one, how to do so objectively? Theyre all interesting questions and well answer each of them in this blog post.

Today, well look at multiple things. In this blog post, well

Are you ready? Lets go!

Lets take a look at the high-level supervised machine learning process:

Training such models goes through a simple, sequential and cyclical process:

2. These predictions are compared with the targets, which represent the ground truth for the features. That is, they are the actual classes in the classification scenario above.

3. The difference between the predictions and the actual targets can be captured in the loss value. Depending on your machine learning problem, you can choose from a wide range of loss functions.

4. Based on the loss value, the model computes the best way of making it better i.e., it computes gradients using backpropagation.

5. Based on these gradients, an optimizer (such as gradient descent or an adaptive optimizer) will adapt the model accordingly.

6. The process starts again. Likely, and hopefully, the model performs slightly better this time.

Once youre happy with the end results, you stop the machine learning process, and you have a model that can hopefully be used in production.

Now, if we wish to understand the concept of the Learning Rate Range Test in more detail, we must take a look at model optimizers. In particular, we should study the concept of a learning rate.

When specifying an optimizer, its possible to configure the learning rate most of the time. For example, the Adam optimizer in Keras (Keras, n.d.):

Indeed, here, the learning rate can be set with learning_rate - and it is set to 0.001 by default.

Now, what is a learning rate? If our goal is to study the Learning Rate Range Test, its critical to understand the concept of a learning rate, isnt it? 😛

Lets go back to step 4 of the machine learning process outlined above: computing gradients with backpropagation.

I always compare optimizing a model with walking down a mountain.

The mountain represents the loss landscape, or how the loss value changes with respect to the particular model state, and your goal is to walk to the valley, where loss is lowest.

This analogy can be used to understand what backpropagation does and why you need learning rates to control it.

Essentially, I like to see backpropagation as a step-computer. While you walk down the mountain, you obviously set steps towards your goal. However, you dont want to miss out on possible shortcuts towards the valley. This requires you to take smaller steps.

Now this is why learning rates are useful: while backpropagation will likely compute relatively large steps, you wish to slow down your descent to allow yourself to look around more thoroughly. Perhaps, youll indeed find that path that brings you to the valley in a shorter amount of time!

So, while backpropagation is a step-computer, the learning rate will allow you to control the size of your steps. While youll take longer to arrive, you might do so more efficiently after all. Especially when the valley is very narrow, you might no longer overstep it because your steps are too large.

This analogy also perfectly explains why the learning rate in the Adam example above was set to learning_rate = 0.001: while it uses the computed gradient for optimization, it makes it 1,000 times smaller first, before using it to change the model weights with the optimizer.

Lets now build in a small intermezzo: the concepts of overfitting and underfitting, and checking for them by using validation and test loss.

Often, before you train a model with all your data, youll first evaluate your choice with hold-out techniques or K-fold Cross Validation. These generate a dataset split between training data and testing data, which youll need, as youre going to need to decide when the model is good enough.

And good enough is the precise balance between having it perform better and having it perform too adequately.

In the first case, which is called underfitting, your model can still improve in a predictive sense. By feeding more samples, and optimizing further, its likely to improve and show better performance over time.

However, when you do so for too long, the model will overfit or adapt too much to your dataset and its idiosyncrasies. As your dataset is a sample, which is drawn from the true population you wish to train for, you face differences between the sample and population means and variances by definition. If your model is over-adapted to your training set, its likely that these differences get in the way when you want to use it for new data from the population. And likely, this will occur when you use your model in production.

Youll therefore always have to strike a balance between the models predictive performance and the models ability to generalize. This is a very intricate balance that can often only be found in a small interval of your training iterations.

Fortunately, its possible to detect overfitting using a plot of your loss value (Smith, 2018). Always take your validation or test loss for this. Use your test loss if you dont split your training data in true training and validation data (which is the case if youre simply evaluating models with e.g. K-fold Cross Validation). Use validation loss if you evaluate models and train the final one at once (requiring training, validation and testing data). In both cases, you ensure that you use data that the model has not seen before, avoiding that you as a student mark your own homework.

This is especially useful when you are using e.g. TensorBoard, where you can inspect progress in real-time.

However, its also possible to generate a plot when your training process finishes. Such diagrams make things crisply clear:

In the first part of the training process, the models predictive performance is clearly improving. Hence, it is underfit during that stage and additional epochs can improve model performance.

However, after about the 20th epoch, validation loss starts improving, while (you must assume this) training loss still decreases. This means that while the model gets better and better in predicting the training data, it is getting worse in predicting the validation data. Hence, after the 20th epoch, overfitting starts to occur.

While you can reduce the impact of overfitting or delay it with regularizers, and Dropout, its clear that for this model and corresponding configuration, the optimum is achieved at the 20th epoch. Whats important to understand here is that this optimum emerges given the model architecture and configuration! If you changed the architecture, or configured it differently, you might e.g. delay overfitting or achieve even lower validation loss minimums. Thats why training neural networks is more of an art than a science.

As choosing a learning rate setting impacts the loss significantly, its good that its clear what overfitting and underfitting are, and how you can spot them on a plot. Lets now take a look at choosing a learning rate.

Which learning rate to choose? What options do I have?

Good questions.

Lets now take a look at two ways of setting a learning rate:

Lets take a look at the Adam optimizer implementation for Keras again (Keras, n.d.):

Here, the learning rate is set as a constant. Its a fixed value which is used in every epoch.

Unfortunately, this doesnt produce an optimal learning process.

Lets take a look at two other models that we trained for another blog post:

The model in orange clearly produces a low loss rapidly, and much faster than the model in blue. However, we can also observe some overfitting to occur after approximately the 10th epoch. Not so weird, given the fact that we trained for ten times longer than strictly necessary.

Now, the rapid descent of the loss value and the increasingly slower pace of falling down are typical for machine learning settings which use optimizers like gradient descent or adaptive ones.

Why is this the case? And why is this important for a learning rate?

Lets dig a little bit deeper.

Supervised machine learning models work with model weights: on initialization, models are configured to accept certain input data, and they create weight vectors in which they can store the numeric patterns they observe. Eventually, they multiply these vectors with the input vectors during training and production usage.

Now, when you start training, its often best practice to initialize your weight vectors randomly, or by using approaches adapted to your model.

For the forward pass (step 1 of the 6 steps outlined at the start), you can imagine that multiplying your input data with random weights will produce very poor results. Indeed, loss is likely high during the first few epochs. However, in this stage, its also possible to make large steps towards accurate weights and hence adequate loss values. Thats why you see loss descend so rapidly during the first few iterations of a supervised ML training process: its looking for a global loss minimum very fast.

However, as you walk down that loss mountain, the number of possible steps that can be taken goes down by function of the number of steps you already set. This is also true for loss landscapes in neural networks: once you get close to the global loss minimum (should it exist), then room for improvement gets tighter and tighter. For this reason, loss balances out (or even gets worse! i.e. overfitting) over time.

This rationale as to why loss values initially decrease substantially while balancing out later on is a substantial issue for our learning rate:

We dont want it to be static.

As we recall, the learning rate essentially tells the model how much of the gradient to use during optimization. Remember that with learning_rate = 0.001 only 1/1000th of the computed gradient is used.

For the latter part of the training process, this would be good, as theres no point in setting large steps. Instead, here, you want to set small ones in order to truly find the global minimum, without overshooting it every time. You might even want to use lower learning rate values here.

However, for the first part of the training process, such low learning rates are problematic. Here, you would actually benefit from large learning rates, for the simple reason that you can afford setting large steps during the first few epochs. Having a small fixed learning rate will thus unnecessarily slow down your learning process or make finding a global minimum in time even impossible!

Hence, a static learning rate is in my opinion not really a good idea when training a neural network.

Now, of course, you can choose to use a static learning rate that lies somewhere between the large and small ones. However, is this really a solution, especially when better solutions are available?

Lets now introduce the concept of a decaying learning rate. Eventually, well now also begin to discover why the Learning Rate Range Test can be useful.

Instead of a fixed learning rate, wouldnt it be good if we could reduce it over time?

Indeed, this seems to be an approach to reducing the negative impact of a fixed learning rate. By using a so-called decay scheme, which decides how the learning rate decays over time, you can exhibit control over the learning rate for an arbitrary epoch.

There are many decay schemes available, and here are four examples:

Linear decay allows you to start with a large learning rate, decay it pretty rapidly, and then keeping it balanced at a static one. Together with step decay, which keeps your learning rate fixed for a set number of epochs, these learning rates are not smooth.

Its also possible to use exponential and time decay, which are in fact smooth. With exponential decay, your learning rate decays rapidly at first, and slower over time but smoothly. Time decay is like a diesel engine: its a slow start, with great performance once the car has velocity, balancing out when its max is reached.

While each has their benefits, there is a wide range of new questions:

These are all important questions and the list is going on and on. Its impractical if not impossible to train your whole architecture every time such a question pops up, to compare. Neither is performing a grid search operation, which is expensive (Smith, 2018). However, especially with respect to the first two questions, there is another way: the Learning Rate Range Test (Smith, 2018).

Lets take a look at what it is and what it does!

With the Learning Rate Range Test, its possible to find an estimate of the optimal learning rate quite quickly and accurately. Smith (2018) gives a perfect introduction to the topic:

It is relatively straight-forward: in a test run, one starts with a very small learning rate, for which one runs the model and computes the loss on the validation data. One does this iteratively, while increasing the learning rate exponentially in parallel. One can then plot their findings into a diagram representing loss at the y axis and the learning rate at the x axis. The x value representing the lowest y value, i.e. the lowest loss, represents the optimal learning rate for the training data.

However, he also argues that

The learning rate at this extrema is the largest value that can be used as the learning rate for the maximum bound with cyclical learning rates but a smaller value will be necessary when choosing a constant learning rate or the network will not begin to converge.

Therefore, well simply pick a value just a tiny bit to the left of the loss minimum.

One such Learning Rate Range Test could, theoretically, yield the following plot:

Its a real plot generated with a ConvNet tested for MNIST data.

We see the fastest learning rate descent at 10^-1.95: in the first plot, the descent is steepest there. The second plot confirms this as it displays the lowest loss delta, i.e. where negative change in loss value (= improvement) was highest given change of learning rate. By consequence, we would choose this learning rate.

Now that we know what the LR Range Test is, its time to implement it with Keras. Fortunately, thats not a difficult thing to do!

Lets take a look.

We need a few dependencies if we wish to run this example successfully. Before you continue, make sure that you have them installed. The dependencies are as follows:

Now, keep your command prompt open, and generate a new file, e.g. touch lr-finder.py. Open this file in a code editor, and you're ready to code.

The first thing I always do is to import everything we need:

Next, we set the configuration for our test scenario. Well use batches of 250 samples for testing. Our images are 28 x 28 pixels and are one-channeled, as the MNIST dataset is grayscale. The number of classes equals 10, while well test for 5 epochs (unless one of the abort conditions, such as a loss value that goes out of the roof, occurs before then). Our estimated start learning rate is 10^-4 while we stop at 10. When generating a plot of our test results, we use a moving average of 20 loss values for smoothing the line, to make our results more interpretable.

The next things we do are related to the dataset:

Then, we specify the model architecture. Its not the most important thing for today, but here it is. Its a simple ConvNet using Max Pooling:

Now, heres the interesting part. We specified the model architecture in our previous step, so we can now decide about which tests we want to perform. For the sake of simplicity, we specify only two, but you can test as much as youd like:

As you can see, the tests that we will perform today will find the best learning rate for the traditional SGD optimizer, and also for the Adam one. Whats great is that by plotting them together (thats what we will do later), we can even compare the performance of the optimizer given this architecture. We can thus also answer the question :Which optimizer produces lowest loss?

Then, we perform the test. For every test, we specify the test_optimizer to be used as well as the label, and compile the model following that particular optimizer. This is followed by instantiating the Learning Rate Range Test through LRFinder, and performing the actual test using the training data and the configuration we specified above.

Once the test has finished this may either be the case because we have completed all epochs, because loss becomes NaN or because loss becomes too large - we take the learning_rates, the losses and loss_changes and store them in containers. However, before storing the loss changes, we smooth them using the moving_average that we defined before. Credits for the smoothing part of the code go to the keras-lr-finder package

After smoothing, we store the learning rates per step, as well as the test losses and the labels, to the containers we specified before. This iteration will ensure that all tests are performed in line with how we want them to perform.

Now that we have the outcomes, we can visualize them! 🙂 Well use Matplotlib for doing so, and well create two plots: one for the loss deltas and one for the actual loss values.

For each, the first thing we do is iterate over the containers, and generate a plot for each test with plt.plot. In our case, this generates two plots, both on top of each other. This is followed by plot configuration - for example, we set the x axis to logarithmic scale, and finally by a popup that visualizes the end result.

All right, you should now have a model that runs!

Open up that terminal again, cd to the folder where your .py file is located (if you're not already there), and run e.g. python lr-finder.py. You should see the epochs begin, and once they finish, two plots similar to these ones should pop up sequentially:

The results are very clear: for this training setting, Adam performs substantially better. We can observe that it reaches a lower loss value compared to SGD (first plot), and that it does so in a much shorter time (second plot the negative delta occurs at a lower learning rate). Likely, this is how we benefit from the fact that Adam performs local parameter updates, whereas SGD does not. If we had to choose between these two optimizers, it would clearly be Adam with a learning rate of 10^-3.95.

Full code is available at my Github repository.

In this blog post, we looked at the Learning Rate Range Test for finding the best learning rate for your neural network empirically.

This was done by looking at the concept of a learning rate before moving to Python code. What is a learning rate? Why is it useful? And how to configure it objectively? Do I need a fixed or a decaying learning rate? Those are all questions that we answered in the first part of this blog post.

In the second part, we introduced the Learning Rate Range Test: a method based on Smith (2018) that allows us to empirically determine the best learning rate for the model and its compile settings that you specify. It even allows us to compare multiple settings at once, and which learning rate is best!

In the third and final part, we used the keras-lr-finder package to implement the Learning Rate Range Test. With blocks of Python code, we explained each step of doing so - and why we set that particular step. This should allow you to use the Learning Rate Range Test in your own projects too.

Read more from the original source:
Finding Optimal Learning Rates. The Learning Rate Range Test | by Francesco Franco | Jan, 2024 - Medium